summaryrefslogtreecommitdiffstats
path: root/store/sql_preference_store_test.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-15 15:09:40 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-15 15:17:07 -0400
commit327b0b5a2119ae888c812f682b3934061b8f59bf (patch)
treed2b91e8649a68ec0b87e4e7349d29965a664b43a /store/sql_preference_store_test.go
parent4b99e1714029689f27ebf4cb078c60367b0594a4 (diff)
downloadchat-327b0b5a2119ae888c812f682b3934061b8f59bf.tar.gz
chat-327b0b5a2119ae888c812f682b3934061b8f59bf.tar.bz2
chat-327b0b5a2119ae888c812f682b3934061b8f59bf.zip
Added an initial call to get all user preferences on page load
Diffstat (limited to 'store/sql_preference_store_test.go')
-rw-r--r--store/sql_preference_store_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/store/sql_preference_store_test.go b/store/sql_preference_store_test.go
index 76b1bcb17..e68203cc3 100644
--- a/store/sql_preference_store_test.go
+++ b/store/sql_preference_store_test.go
@@ -144,3 +144,51 @@ func TestPreferenceGetCategory(t *testing.T) {
t.Fatal("shouldn't have got any preferences")
}
}
+
+func TestPreferenceGetAll(t *testing.T) {
+ Setup()
+
+ userId := model.NewId()
+ category := model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW
+ name := model.NewId()
+
+ preferences := model.Preferences{
+ {
+ UserId: userId,
+ Category: category,
+ Name: name,
+ },
+ // same user/category, different name
+ {
+ UserId: userId,
+ Category: category,
+ Name: model.NewId(),
+ },
+ // same user/name, different category
+ {
+ UserId: userId,
+ Category: model.NewId(),
+ Name: name,
+ },
+ // same name/category, different user
+ {
+ UserId: model.NewId(),
+ Category: category,
+ Name: name,
+ },
+ }
+
+ Must(store.Preference().Save(&preferences))
+
+ if result := <-store.Preference().GetAll(userId); result.Err != nil {
+ t.Fatal(result.Err)
+ } else if data := result.Data.(model.Preferences); len(data) != 3 {
+ t.Fatal("got the wrong number of preferences")
+ } else {
+ for i := 0; i < 3; i++ {
+ if data[0] != preferences[i] && data[1] != preferences[i] && data[2] != preferences[i] {
+ t.Fatal("got incorrect preferences")
+ }
+ }
+ }
+}