summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-12-09 18:43:03 -0500
committerCorey Hulen <corey@hulen.com>2016-12-09 15:43:03 -0800
commitaaa41535f8ac9656d0cd399aeedf58de9b374b65 (patch)
tree34d15671bf4b6f50fdb96a0fe1f1967885d87931 /store/sql_channel_store_test.go
parent9670afed82e6c3192d230f107b836e21bb0c01a6 (diff)
downloadchat-aaa41535f8ac9656d0cd399aeedf58de9b374b65.tar.gz
chat-aaa41535f8ac9656d0cd399aeedf58de9b374b65.tar.bz2
chat-aaa41535f8ac9656d0cd399aeedf58de9b374b65.zip
PLT-3736 Fixed duplicated create_direct api calls not returning the existing channel (#4745)
* Fixed duplicated create_direct api calls not returning the existing channel * Added unit tests for duplicated create_direct api calls
Diffstat (limited to 'store/sql_channel_store_test.go')
-rw-r--r--store/sql_channel_store_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index 9b77639b0..d4bcf6b26 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -88,6 +88,23 @@ func TestChannelStoreSaveDirectChannel(t *testing.T) {
t.Fatal("shouldn't be able to update from save")
}
+ // Attempt to save a direct channel that already exists
+ o1a := model.Channel{
+ TeamId: o1.TeamId,
+ DisplayName: o1.DisplayName,
+ Name: o1.Name,
+ Type: o1.Type,
+ }
+
+ if result := <-store.Channel().SaveDirectChannel(&o1a, &m1, &m2); result.Err == nil {
+ t.Fatal("should've failed to save a duplicate direct channel")
+ } else if result.Err.Id != CHANNEL_EXISTS_ERROR {
+ t.Fatal("should've returned CHANNEL_EXISTS_ERROR")
+ } else if returned := result.Data.(*model.Channel); returned.Id != o1.Id {
+ t.Fatal("should've returned original channel when saving a duplicate direct channel")
+ }
+
+ // Attempt to save a non-direct channel
o1.Id = ""
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN