From 1bb85818ca5d7569c17e56d523d9668b83973e65 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 22 Feb 2016 16:08:40 -0800 Subject: Fixing device id column for droid --- store/sql_store_test.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'store/sql_store_test.go') 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") + } +} -- cgit v1.2.3-1-g7c22