summaryrefslogtreecommitdiffstats
path: root/store/sql_webhook_store_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-07-31 08:52:45 -0700
committerHarrison Healey <harrisonmhealey@gmail.com>2017-07-31 11:52:45 -0400
commit72f61ab96aabf65c162c8d94b5b843b5108ee1a9 (patch)
treec80d7158613663a0b3f584a1736ef1cbff72d160 /store/sql_webhook_store_test.go
parent0f786a42d3289df9b4f5bdb4bddb0ecb07631608 (diff)
downloadchat-72f61ab96aabf65c162c8d94b5b843b5108ee1a9.tar.gz
chat-72f61ab96aabf65c162c8d94b5b843b5108ee1a9.tar.bz2
chat-72f61ab96aabf65c162c8d94b5b843b5108ee1a9.zip
make cli team / channel delete operations also delete webhooks and slash commands (#7028)
Diffstat (limited to 'store/sql_webhook_store_test.go')
-rw-r--r--store/sql_webhook_store_test.go55
1 files changed, 52 insertions, 3 deletions
diff --git a/store/sql_webhook_store_test.go b/store/sql_webhook_store_test.go
index f5e328b32..ea15b9caa 100644
--- a/store/sql_webhook_store_test.go
+++ b/store/sql_webhook_store_test.go
@@ -157,7 +157,29 @@ func TestWebhookStoreDeleteIncoming(t *testing.T) {
t.Fatal(r2.Err)
}
- ClearWebhookCaches()
+ if r3 := (<-store.Webhook().GetIncoming(o1.Id, true)); r3.Err == nil {
+ t.Log(r3.Data)
+ t.Fatal("Missing id should have failed")
+ }
+}
+
+func TestWebhookStoreDeleteIncomingByChannel(t *testing.T) {
+ Setup()
+ o1 := buildIncomingWebhook()
+
+ o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
+
+ if r1 := <-store.Webhook().GetIncoming(o1.Id, true); 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().PermanentDeleteIncomingByChannel(o1.ChannelId); r2.Err != nil {
+ t.Fatal(r2.Err)
+ }
if r3 := (<-store.Webhook().GetIncoming(o1.Id, true)); r3.Err == nil {
t.Log(r3.Data)
@@ -183,8 +205,6 @@ func TestWebhookStoreDeleteIncomingByUser(t *testing.T) {
t.Fatal(r2.Err)
}
- ClearWebhookCaches()
-
if r3 := (<-store.Webhook().GetIncoming(o1.Id, true)); r3.Err == nil {
t.Log(r3.Data)
t.Fatal("Missing id should have failed")
@@ -380,6 +400,35 @@ func TestWebhookStoreDeleteOutgoing(t *testing.T) {
}
}
+func TestWebhookStoreDeleteOutgoingByChannel(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().PermanentDeleteOutgoingByChannel(o1.ChannelId); 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 TestWebhookStoreDeleteOutgoingByUser(t *testing.T) {
Setup()