diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-01-25 09:32:42 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-01-25 09:32:42 -0500 |
commit | d245b29f82a03f1aff966a2fb2100a5703d82f32 (patch) | |
tree | cf204039af74fa2579e0291e9e595f08411b0a7a /store/sql_preference_store_test.go | |
parent | 8ed665cb76c0763e83a2949c4bdd70153baf72f7 (diff) | |
download | chat-d245b29f82a03f1aff966a2fb2100a5703d82f32.tar.gz chat-d245b29f82a03f1aff966a2fb2100a5703d82f32.tar.bz2 chat-d245b29f82a03f1aff966a2fb2100a5703d82f32.zip |
More app code migration (#5170)
* Migrate admin functions into app package
* More user function refactoring
* Move post functions into app package
Diffstat (limited to 'store/sql_preference_store_test.go')
-rw-r--r-- | store/sql_preference_store_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/store/sql_preference_store_test.go b/store/sql_preference_store_test.go index fc1cf5f5b..adcaa8d89 100644 --- a/store/sql_preference_store_test.go +++ b/store/sql_preference_store_test.go @@ -427,3 +427,48 @@ func TestPreferenceDeleteCategory(t *testing.T) { t.Fatal("should've returned no preferences") } } + +func TestPreferenceDeleteCategoryAndName(t *testing.T) { + Setup() + + category := model.NewId() + name := model.NewId() + userId := model.NewId() + userId2 := model.NewId() + + preference1 := model.Preference{ + UserId: userId, + Category: category, + Name: name, + Value: "value1a", + } + + preference2 := model.Preference{ + UserId: userId2, + Category: category, + Name: name, + Value: "value1a", + } + + Must(store.Preference().Save(&model.Preferences{preference1, preference2})) + + if prefs := Must(store.Preference().GetAll(userId)).(model.Preferences); len([]model.Preference(prefs)) != 1 { + t.Fatal("should've returned 1 preference") + } + + if prefs := Must(store.Preference().GetAll(userId2)).(model.Preferences); len([]model.Preference(prefs)) != 1 { + t.Fatal("should've returned 1 preference") + } + + if result := <-store.Preference().DeleteCategoryAndName(category, name); result.Err != nil { + t.Fatal(result.Err) + } + + if prefs := Must(store.Preference().GetAll(userId)).(model.Preferences); len([]model.Preference(prefs)) != 0 { + t.Fatal("should've returned no preferences") + } + + if prefs := Must(store.Preference().GetAll(userId2)).(model.Preferences); len([]model.Preference(prefs)) != 0 { + t.Fatal("should've returned no preferences") + } +} |