diff --git a/tests/migrate_test.go b/tests/migrate_test.go index 7ad22de6..2577c0c2 100644 --- a/tests/migrate_test.go +++ b/tests/migrate_test.go @@ -385,6 +385,10 @@ func TestMigrateIndexes(t *testing.T) { t.Fatalf("Should not find index for user's name after delete") } + if err := DB.Migrator().CreateIndex("index_structs", "idx_index_structs_name"); err == nil { + t.Fatalf("should failed to create index with table name") + } + if err := DB.Migrator().CreateIndex(&IndexStruct{}, "Name"); err != nil { t.Fatalf("Got error when tried to create index: %+v", err) } @@ -562,6 +566,9 @@ func TestMigrateColumns(t *testing.T) { if err := DB.Table("column_structs").Migrator().AlterColumn(&ColumnStruct{}, "Name"); err != nil { t.Fatalf("no error should happened when alter column, but got %v", err) } + if err := DB.Migrator().AlterColumn("column_structs", "Name"); err == nil { + t.Errorf("should failed to alter column with table name") + } if err := DB.Table("column_structs").AutoMigrate(&ColumnStruct2{}); err != nil { t.Fatalf("no error should happened when auto migrate column, but got %v", err) @@ -659,6 +666,10 @@ func TestMigrateColumns(t *testing.T) { t.Fatalf("Found deleted column") } + if err := DB.Migrator().AddColumn("column_structs", "new_name"); err == nil { + t.Fatalf("should failed to add column with table name") + } + if err := DB.Table("column_structs").Migrator().AddColumn(&NewColumnStruct{}, "NewName"); err != nil { t.Fatalf("Failed to add column, got %v", err) }