Fixing device id column for droid

Этот коммит содержится в:
=Corey Hulen
2016-02-22 16:08:40 -08:00
родитель 32ae72d91d
Коммит 1bb85818ca
6 изменённых файлов: 179 добавлений и 18 удалений

Просмотреть файл

@@ -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")
}
}