diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-25 09:11:25 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-09-25 10:11:25 -0400 |
commit | 49fe5fbf3db56fc466b8997b182ee135d7a4365d (patch) | |
tree | 1252fea09aa3ce899e2e8edb1fb7b42900f50bca /store/sql_command_store_test.go | |
parent | b2c5b97601b61f5748b46e4e386134203111ebb0 (diff) | |
download | chat-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_store_test.go')
-rw-r--r-- | store/sql_command_store_test.go | 221 |
1 files changed, 0 insertions, 221 deletions
diff --git a/store/sql_command_store_test.go b/store/sql_command_store_test.go deleted file mode 100644 index f6b410429..000000000 --- a/store/sql_command_store_test.go +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -package store - -import ( - "testing" - - "github.com/mattermost/mattermost-server/model" -) - -func TestCommandStoreSave(t *testing.T) { - 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 = "trigger" - - if err := (<-store.Command().Save(&o1)).Err; err != nil { - t.Fatal("couldn't save item", err) - } - - if err := (<-store.Command().Save(&o1)).Err; err == nil { - t.Fatal("shouldn't be able to update from save") - } -} - -func TestCommandStoreGet(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - if r1 := <-store.Command().Get(o1.Id); r1.Err != nil { - t.Fatal(r1.Err) - } else { - if r1.Data.(*model.Command).CreateAt != o1.CreateAt { - t.Fatal("invalid returned command") - } - } - - if err := (<-store.Command().Get("123")).Err; err == nil { - t.Fatal("Missing id should have failed") - } -} - -func TestCommandStoreGetByTeam(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - if r1 := <-store.Command().GetByTeam(o1.TeamId); r1.Err != nil { - t.Fatal(r1.Err) - } else { - if r1.Data.([]*model.Command)[0].CreateAt != o1.CreateAt { - t.Fatal("invalid returned command") - } - } - - if result := <-store.Command().GetByTeam("123"); result.Err != nil { - t.Fatal(result.Err) - } else { - if len(result.Data.([]*model.Command)) != 0 { - t.Fatal("no commands should have returned") - } - } -} - -func TestCommandStoreDelete(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - if r1 := <-store.Command().Get(o1.Id); r1.Err != nil { - t.Fatal(r1.Err) - } else { - if r1.Data.(*model.Command).CreateAt != o1.CreateAt { - t.Fatal("invalid returned command") - } - } - - if r2 := <-store.Command().Delete(o1.Id, model.GetMillis()); r2.Err != nil { - t.Fatal(r2.Err) - } - - if r3 := (<-store.Command().Get(o1.Id)); r3.Err == nil { - t.Log(r3.Data) - t.Fatal("Missing id should have failed") - } -} - -func TestCommandStoreDeleteByTeam(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - if r1 := <-store.Command().Get(o1.Id); r1.Err != nil { - t.Fatal(r1.Err) - } else { - if r1.Data.(*model.Command).CreateAt != o1.CreateAt { - t.Fatal("invalid returned command") - } - } - - if r2 := <-store.Command().PermanentDeleteByTeam(o1.TeamId); r2.Err != nil { - t.Fatal(r2.Err) - } - - if r3 := (<-store.Command().Get(o1.Id)); r3.Err == nil { - t.Log(r3.Data) - t.Fatal("Missing id should have failed") - } -} - -func TestCommandStoreDeleteByUser(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - if r1 := <-store.Command().Get(o1.Id); r1.Err != nil { - t.Fatal(r1.Err) - } else { - if r1.Data.(*model.Command).CreateAt != o1.CreateAt { - t.Fatal("invalid returned command") - } - } - - if r2 := <-store.Command().PermanentDeleteByUser(o1.CreatorId); r2.Err != nil { - t.Fatal(r2.Err) - } - - if r3 := (<-store.Command().Get(o1.Id)); r3.Err == nil { - t.Log(r3.Data) - t.Fatal("Missing id should have failed") - } -} - -func TestCommandStoreUpdate(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - o1.Token = model.NewId() - - if r2 := <-store.Command().Update(o1); r2.Err != nil { - t.Fatal(r2.Err) - } -} - -func TestCommandCount(t *testing.T) { - 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 = "trigger" - - o1 = (<-store.Command().Save(o1)).Data.(*model.Command) - - if r1 := <-store.Command().AnalyticsCommandCount(""); r1.Err != nil { - t.Fatal(r1.Err) - } else { - if r1.Data.(int64) == 0 { - t.Fatal("should be at least 1 command") - } - } - - if r2 := <-store.Command().AnalyticsCommandCount(o1.TeamId); r2.Err != nil { - t.Fatal(r2.Err) - } else { - if r2.Data.(int64) != 1 { - t.Fatal("should be 1 command") - } - } -} |