diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-02-23 09:47:38 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-02-23 09:47:38 -0500 |
commit | 490e64352536336548ecbaea5f1ba1c0209fe2f7 (patch) | |
tree | 61141e22591cd6c928b8276877a9c1d50d8d814e /store/sql_store_test.go | |
parent | 3f3718a007fb824bbb50199813fdaa83ad17c7eb (diff) | |
parent | 28ab0d835878bf1ad72dbae914ca112acfbe490d (diff) | |
download | chat-490e64352536336548ecbaea5f1ba1c0209fe2f7.tar.gz chat-490e64352536336548ecbaea5f1ba1c0209fe2f7.tar.bz2 chat-490e64352536336548ecbaea5f1ba1c0209fe2f7.zip |
Merge pull request #2217 from mattermost/fix-droid
Fixing device id column for droid
Diffstat (limited to 'store/sql_store_test.go')
-rw-r--r-- | store/sql_store_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/store/sql_store_test.go b/store/sql_store_test.go index 1be87dec9..474a68ac7 100644 --- a/store/sql_store_test.go +++ b/store/sql_store_test.go @@ -85,3 +85,63 @@ func TestEncrypt(t *testing.T) { t.Fatal("error in encrypt") } } + +func TestAlertDbCmds(t *testing.T) { + Setup() + + sqlStore := store.(*SqlStore) + + if !sqlStore.DoesTableExist("Systems") { + t.Fatal("Failed table exists") + } + + if sqlStore.DoesColumnExist("Systems", "Test") { + t.Fatal("Column should not exist") + } + + if !sqlStore.CreateColumnIfNotExists("Systems", "Test", "VARCHAR(50)", "VARCHAR(50)", "") { + t.Fatal("Failed to create column") + } + + maxLen := sqlStore.GetMaxLengthOfColumnIfExists("Systems", "Test") + + if maxLen != "50" { + t.Fatal("Failed to get max length found " + maxLen) + } + + if !sqlStore.AlterColumnTypeIfExists("Systems", "Test", "VARCHAR(25)", "VARCHAR(25)") { + t.Fatal("failed to alter column size") + } + + maxLen2 := sqlStore.GetMaxLengthOfColumnIfExists("Systems", "Test") + + if maxLen2 != "25" { + t.Fatal("Failed to get max length") + } + + if !sqlStore.RenameColumnIfExists("Systems", "Test", "Test1", "VARCHAR(25)") { + t.Fatal("Failed to rename column") + } + + if sqlStore.DoesColumnExist("Systems", "Test") { + t.Fatal("Column should not exist") + } + + if !sqlStore.DoesColumnExist("Systems", "Test1") { + t.Fatal("Column should exist") + } + + sqlStore.CreateIndexIfNotExists("idx_systems_test1", "Systems", "Test1") + sqlStore.RemoveIndexIfExists("idx_systems_test1", "Systems") + + sqlStore.CreateFullTextIndexIfNotExists("idx_systems_test1", "Systems", "Test1") + sqlStore.RemoveIndexIfExists("idx_systems_test1", "Systems") + + if !sqlStore.RemoveColumnIfExists("Systems", "Test1") { + t.Fatal("Failed to remove columns") + } + + if sqlStore.DoesColumnExist("Systems", "Test1") { + t.Fatal("Column should not exist") + } +} |