summaryrefslogtreecommitdiffstats
path: root/store/sqlstore/command_store_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sqlstore/command_store_test.go')
-rw-r--r--store/sqlstore/command_store_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/store/sqlstore/command_store_test.go b/store/sqlstore/command_store_test.go
index 85eed64cc..407eae72e 100644
--- a/store/sqlstore/command_store_test.go
+++ b/store/sqlstore/command_store_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/mattermost/mattermost-server/model"
+ "github.com/mattermost/mattermost-server/store"
)
func TestCommandStoreSave(t *testing.T) {
@@ -82,6 +83,41 @@ func TestCommandStoreGetByTeam(t *testing.T) {
}
}
+func TestCommandStoreGetByTrigger(t *testing.T) {
+ ss := Setup()
+
+ o1 := &model.Command{}
+ o1.CreatorId = model.NewId()
+ o1.Method = model.COMMAND_METHOD_POST
+ o1.TeamId = model.NewId()
+ o1.URL = "http://nowhere.com/"
+ o1.Trigger = "trigger1"
+
+ o2 := &model.Command{}
+ o2.CreatorId = model.NewId()
+ o2.Method = model.COMMAND_METHOD_POST
+ o2.TeamId = model.NewId()
+ o2.URL = "http://nowhere.com/"
+ o2.Trigger = "trigger1"
+
+ o1 = (<-ss.Command().Save(o1)).Data.(*model.Command)
+ o2 = (<-ss.Command().Save(o2)).Data.(*model.Command)
+
+ if r1 := <-ss.Command().GetByTrigger(o1.TeamId, o1.Trigger); r1.Err != nil {
+ t.Fatal(r1.Err)
+ } else {
+ if r1.Data.(*model.Command).Id != o1.Id {
+ t.Fatal("invalid returned command")
+ }
+ }
+
+ store.Must(ss.Command().Delete(o1.Id, model.GetMillis()))
+
+ if result := <-ss.Command().GetByTrigger(o1.TeamId, o1.Trigger); result.Err == nil {
+ t.Fatal("no commands should have returned")
+ }
+}
+
func TestCommandStoreDelete(t *testing.T) {
ss := Setup()