diff options
author | =Corey Hulen <corey@hulen.com> | 2015-11-15 18:18:02 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-11-16 11:34:29 -0800 |
commit | 03c6dcbd865e2af2db5db150189504bfa493ae2e (patch) | |
tree | 360d2ece83de79d3df338d581216e4282b420209 /store/sql_webhook_store_test.go | |
parent | 48d2f86b90b3e0b02cb28f3e8b6e4d454f9cb869 (diff) | |
download | chat-03c6dcbd865e2af2db5db150189504bfa493ae2e.tar.gz chat-03c6dcbd865e2af2db5db150189504bfa493ae2e.tar.bz2 chat-03c6dcbd865e2af2db5db150189504bfa493ae2e.zip |
PLT-975 adding perm deletes
Diffstat (limited to 'store/sql_webhook_store_test.go')
-rw-r--r-- | store/sql_webhook_store_test.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/store/sql_webhook_store_test.go b/store/sql_webhook_store_test.go index 1fb990f3e..1b770c6d4 100644 --- a/store/sql_webhook_store_test.go +++ b/store/sql_webhook_store_test.go @@ -103,6 +103,34 @@ func TestWebhookStoreDeleteIncoming(t *testing.T) { } } +func TestWebhookStoreDeleteIncomingByUser(t *testing.T) { + Setup() + + o1 := &model.IncomingWebhook{} + o1.ChannelId = model.NewId() + o1.UserId = model.NewId() + o1.TeamId = model.NewId() + + o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook) + + if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil { + t.Fatal(r1.Err) + } else { + if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt { + t.Fatal("invalid returned webhook") + } + } + + if r2 := <-store.Webhook().DeleteIncomingByUser(o1.UserId); r2.Err != nil { + t.Fatal(r2.Err) + } + + if r3 := (<-store.Webhook().GetIncoming(o1.Id)); r3.Err == nil { + t.Log(r3.Data) + t.Fatal("Missing id should have failed") + } +} + func TestWebhookStoreSaveOutgoing(t *testing.T) { Setup() @@ -258,6 +286,35 @@ func TestWebhookStoreDeleteOutgoing(t *testing.T) { } } +func TestWebhookStoreDeleteOutgoingByUser(t *testing.T) { + Setup() + + o1 := &model.OutgoingWebhook{} + o1.ChannelId = model.NewId() + o1.CreatorId = model.NewId() + o1.TeamId = model.NewId() + o1.CallbackURLs = []string{"http://nowhere.com/"} + + o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook) + + if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil { + t.Fatal(r1.Err) + } else { + if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt { + t.Fatal("invalid returned webhook") + } + } + + if r2 := <-store.Webhook().DeleteOutgoingByUser(o1.CreatorId); r2.Err != nil { + t.Fatal(r2.Err) + } + + if r3 := (<-store.Webhook().GetOutgoing(o1.Id)); r3.Err == nil { + t.Log(r3.Data) + t.Fatal("Missing id should have failed") + } +} + func TestWebhookStoreUpdateOutgoing(t *testing.T) { Setup() |