summaryrefslogtreecommitdiffstats
path: root/store/sql_command_webhook_store_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-25 09:11:25 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-09-25 10:11:25 -0400
commit49fe5fbf3db56fc466b8997b182ee135d7a4365d (patch)
tree1252fea09aa3ce899e2e8edb1fb7b42900f50bca /store/sql_command_webhook_store_test.go
parentb2c5b97601b61f5748b46e4e386134203111ebb0 (diff)
downloadchat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.tar.gz
chat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.tar.bz2
chat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.zip
Move sql store code into store/sqlstore package (#7502)
* move sql store code into store/sqlstore package * move non-sql constants back up to store * fix api test * derp
Diffstat (limited to 'store/sql_command_webhook_store_test.go')
-rw-r--r--store/sql_command_webhook_store_test.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/store/sql_command_webhook_store_test.go b/store/sql_command_webhook_store_test.go
deleted file mode 100644
index 3236915dd..000000000
--- a/store/sql_command_webhook_store_test.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package store
-
-import (
- "testing"
-
- "net/http"
-
- "github.com/mattermost/mattermost-server/model"
-)
-
-func TestCommandWebhookStore(t *testing.T) {
- Setup()
-
- cws := store.CommandWebhook()
-
- h1 := &model.CommandWebhook{}
- h1.CommandId = model.NewId()
- h1.UserId = model.NewId()
- h1.ChannelId = model.NewId()
- h1 = (<-cws.Save(h1)).Data.(*model.CommandWebhook)
-
- if r1 := <-cws.Get(h1.Id); r1.Err != nil {
- t.Fatal(r1.Err)
- } else {
- if *r1.Data.(*model.CommandWebhook) != *h1 {
- t.Fatal("invalid returned webhook")
- }
- }
-
- if err := (<-cws.Get("123")).Err; err.StatusCode != http.StatusNotFound {
- t.Fatal("Should have set the status as not found for missing id")
- }
-
- h2 := &model.CommandWebhook{}
- h2.CreateAt = model.GetMillis() - 2*model.COMMAND_WEBHOOK_LIFETIME
- h2.CommandId = model.NewId()
- h2.UserId = model.NewId()
- h2.ChannelId = model.NewId()
- h2 = (<-cws.Save(h2)).Data.(*model.CommandWebhook)
-
- if err := (<-cws.Get(h2.Id)).Err; err == nil || err.StatusCode != http.StatusNotFound {
- t.Fatal("Should have set the status as not found for expired webhook")
- }
-
- cws.Cleanup()
-
- if err := (<-cws.Get(h1.Id)).Err; err != nil {
- t.Fatal("Should have no error getting unexpired webhook")
- }
-
- if err := (<-cws.Get(h2.Id)).Err; err.StatusCode != http.StatusNotFound {
- t.Fatal("Should have set the status as not found for expired webhook")
- }
-
- if err := (<-cws.TryUse(h1.Id, 1)).Err; err != nil {
- t.Fatal("Should be able to use webhook once")
- }
-
- if err := (<-cws.TryUse(h1.Id, 1)).Err; err == nil || err.StatusCode != http.StatusBadRequest {
- t.Fatal("Should be able to use webhook once")
- }
-}