summaryrefslogtreecommitdiffstats
path: root/store/sql_store_test.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-02-22 16:08:40 -0800
committer=Corey Hulen <corey@hulen.com>2016-02-22 16:08:40 -0800
commit1bb85818ca5d7569c17e56d523d9668b83973e65 (patch)
tree5b40290c7a65678171cfc236ffc1cd72e88027cf /store/sql_store_test.go
parent32ae72d91d31699899d5e2084cf7faa40c81e42c (diff)
downloadchat-1bb85818ca5d7569c17e56d523d9668b83973e65.tar.gz
chat-1bb85818ca5d7569c17e56d523d9668b83973e65.tar.bz2
chat-1bb85818ca5d7569c17e56d523d9668b83973e65.zip
Fixing device id column for droid
Diffstat (limited to 'store/sql_store_test.go')
-rw-r--r--store/sql_store_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/store/sql_store_test.go b/store/sql_store_test.go
index 1be87dec9..783d72b83 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")
+ }
+
+ 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")
+ }
+}