summaryrefslogtreecommitdiffstats
path: root/store/sql_webhook_store_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-11-18 12:48:45 -0500
committerJoram Wilander <jwawilander@gmail.com>2015-11-18 12:48:45 -0500
commite408d615c02ae3c863df3c7dc13d1b813c22fd28 (patch)
treea1c607b7721831c71aadbf89f018ed7b11a0e426 /store/sql_webhook_store_test.go
parent9660adb00775aba822d2d684d215c55679a456c6 (diff)
parentc115191d6b5abdefda856c063e3f9048dc82f830 (diff)
downloadchat-e408d615c02ae3c863df3c7dc13d1b813c22fd28.tar.gz
chat-e408d615c02ae3c863df3c7dc13d1b813c22fd28.tar.bz2
chat-e408d615c02ae3c863df3c7dc13d1b813c22fd28.zip
Merge pull request #1448 from mattermost/PLT-975
PLT-975 adding delete to command line tool
Diffstat (limited to 'store/sql_webhook_store_test.go')
-rw-r--r--store/sql_webhook_store_test.go57
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..1a9d5be3b 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().PermanentDeleteIncomingByUser(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().PermanentDeleteOutgoingByUser(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()