From 03c6dcbd865e2af2db5db150189504bfa493ae2e Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sun, 15 Nov 2015 18:18:02 -0800 Subject: PLT-975 adding perm deletes --- store/sql_webhook_store_test.go | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'store/sql_webhook_store_test.go') 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() -- cgit v1.2.3-1-g7c22 From 6b2eabf6108e078bed8143e91c605dec5ccfafa6 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 16 Nov 2015 17:12:49 -0800 Subject: Adding perm delete to cmd line --- store/sql_webhook_store_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'store/sql_webhook_store_test.go') diff --git a/store/sql_webhook_store_test.go b/store/sql_webhook_store_test.go index 1b770c6d4..1a9d5be3b 100644 --- a/store/sql_webhook_store_test.go +++ b/store/sql_webhook_store_test.go @@ -121,7 +121,7 @@ func TestWebhookStoreDeleteIncomingByUser(t *testing.T) { } } - if r2 := <-store.Webhook().DeleteIncomingByUser(o1.UserId); r2.Err != nil { + if r2 := <-store.Webhook().PermanentDeleteIncomingByUser(o1.UserId); r2.Err != nil { t.Fatal(r2.Err) } @@ -305,7 +305,7 @@ func TestWebhookStoreDeleteOutgoingByUser(t *testing.T) { } } - if r2 := <-store.Webhook().DeleteOutgoingByUser(o1.CreatorId); r2.Err != nil { + if r2 := <-store.Webhook().PermanentDeleteOutgoingByUser(o1.CreatorId); r2.Err != nil { t.Fatal(r2.Err) } -- cgit v1.2.3-1-g7c22