summaryrefslogtreecommitdiffstats
path: root/store/sql_store_test.go
diff options
context:
space:
mode:
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")
+ }
+}