summaryrefslogtreecommitdiffstats
path: root/store/sql_store_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-01-18 08:50:01 -0500
committerGitHub <noreply@github.com>2017-01-18 08:50:01 -0500
commitdd6fac50f2741ecc8e7e07c42a3e94b37720bd5e (patch)
treedac3eea7eb0fbe6b4cef0cb7e90da9c11ca58993 /store/sql_store_test.go
parent976296cd52533ff565407e55e872339cc312a0cf (diff)
downloadchat-dd6fac50f2741ecc8e7e07c42a3e94b37720bd5e.tar.gz
chat-dd6fac50f2741ecc8e7e07c42a3e94b37720bd5e.tar.bz2
chat-dd6fac50f2741ecc8e7e07c42a3e94b37720bd5e.zip
Removed index on Teams.Description column (#5095)
* Removed index on Teams.Description column * Fixed RemoveIndexIfExists when running with MySQL * Fixed RemoveIndexIfExists when running Postgres and added unit tests
Diffstat (limited to 'store/sql_store_test.go')
-rw-r--r--store/sql_store_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/store/sql_store_test.go b/store/sql_store_test.go
index d65d591ad..3c6081e3c 100644
--- a/store/sql_store_test.go
+++ b/store/sql_store_test.go
@@ -118,3 +118,51 @@ func TestAlertDbCmds(t *testing.T) {
t.Fatal("Column should not exist")
}
}
+
+func TestCreateIndexIfNotExists(t *testing.T) {
+ Setup()
+
+ sqlStore := store.(*SqlStore)
+
+ defer sqlStore.RemoveColumnIfExists("Systems", "Test")
+ if !sqlStore.CreateColumnIfNotExists("Systems", "Test", "VARCHAR(50)", "VARCHAR(50)", "") {
+ t.Fatal("Failed to create test column")
+ }
+
+ defer sqlStore.RemoveIndexIfExists("idx_systems_create_index_test", "Systems")
+ if !sqlStore.CreateIndexIfNotExists("idx_systems_create_index_test", "Systems", "Test") {
+ t.Fatal("Should've created test index")
+ }
+
+ if sqlStore.CreateIndexIfNotExists("idx_systems_create_index_test", "Systems", "Test") {
+ t.Fatal("Shouldn't have created index that already exists")
+ }
+}
+
+func TestRemoveIndexIfExists(t *testing.T) {
+ Setup()
+
+ sqlStore := store.(*SqlStore)
+
+ defer sqlStore.RemoveColumnIfExists("Systems", "Test")
+ if !sqlStore.CreateColumnIfNotExists("Systems", "Test", "VARCHAR(50)", "VARCHAR(50)", "") {
+ t.Fatal("Failed to create test column")
+ }
+
+ if sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems") {
+ t.Fatal("Should've failed to remove index that doesn't exist")
+ }
+
+ defer sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems")
+ if !sqlStore.CreateIndexIfNotExists("idx_systems_remove_index_test", "Systems", "Test") {
+ t.Fatal("Should've created test index")
+ }
+
+ if !sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems") {
+ t.Fatal("Should've removed index that exists")
+ }
+
+ if sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems") {
+ t.Fatal("Should've failed to remove index that was already removed")
+ }
+}