diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-10-13 15:18:01 -0400 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-10-13 15:36:58 -0400 |
commit | 97b2f6ffe7fa09a2188163740865322582b00b59 (patch) | |
tree | 69c11911d8c364b8d6bb31c2723a8f046b8b61e3 /store/sql_preference_store_test.go | |
parent | 2a39e8dbfab8506b09d0d030f87cac4c079b975a (diff) | |
download | chat-97b2f6ffe7fa09a2188163740865322582b00b59.tar.gz chat-97b2f6ffe7fa09a2188163740865322582b00b59.tar.bz2 chat-97b2f6ffe7fa09a2188163740865322582b00b59.zip |
Made further changes based on feedback
Diffstat (limited to 'store/sql_preference_store_test.go')
-rw-r--r-- | store/sql_preference_store_test.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/store/sql_preference_store_test.go b/store/sql_preference_store_test.go index 1feda01d9..76b1bcb17 100644 --- a/store/sql_preference_store_test.go +++ b/store/sql_preference_store_test.go @@ -55,7 +55,7 @@ func TestPreferenceGet(t *testing.T) { userId := model.NewId() category := model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW - name := model.PREFERENCE_NAME_TEST + name := model.NewId() preferences := model.Preferences{ { @@ -70,7 +70,7 @@ func TestPreferenceGet(t *testing.T) { }, { UserId: userId, - Category: model.PREFERENCE_CATEGORY_TEST, + Category: model.NewId(), Name: name, }, { @@ -87,6 +87,11 @@ func TestPreferenceGet(t *testing.T) { } else if data := result.Data.(model.Preference); data != preferences[0] { t.Fatal("got incorrect preference") } + + // make sure getting a missing preference fails + if result := <-store.Preference().Get(model.NewId(), model.NewId(), model.NewId()); result.Err == nil { + t.Fatal("no error on getting a missing preference") + } } func TestPreferenceGetCategory(t *testing.T) { @@ -111,7 +116,7 @@ func TestPreferenceGetCategory(t *testing.T) { // same user/name, different category { UserId: userId, - Category: model.PREFERENCE_CATEGORY_TEST, + Category: model.NewId(), Name: name, }, // same name/category, different user @@ -131,4 +136,11 @@ func TestPreferenceGetCategory(t *testing.T) { } else if !((data[0] == preferences[0] && data[1] == preferences[1]) || (data[0] == preferences[1] && data[1] == preferences[0])) { t.Fatal("got incorrect preferences") } + + // make sure getting a missing preference category doesn't fail + if result := <-store.Preference().GetCategory(model.NewId(), model.NewId()); result.Err != nil { + t.Fatal(result.Err) + } else if data := result.Data.(model.Preferences); len(data) != 0 { + t.Fatal("shouldn't have got any preferences") + } } |