Add test that provokes the race condition
This commit is contained in:
parent
40f4afe8c2
commit
34440dafd8
@ -1685,3 +1685,29 @@ func TestTableType(t *testing.T) {
|
|||||||
t.Fatalf("expected comment %s got %s", tblComment, comment)
|
t.Fatalf("expected comment %s got %s", tblComment, comment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMigrateRaceCondition(t *testing.T) {
|
||||||
|
type TestTable struct {
|
||||||
|
gorm.Model
|
||||||
|
}
|
||||||
|
|
||||||
|
for a := 0; a < 2; a++ {
|
||||||
|
t.Run("drop and migrate", func(t *testing.T) {
|
||||||
|
t.Run("drop", func(t *testing.T) {
|
||||||
|
if err := DB.Migrator().DropTable(&TestTable{}); err != nil {
|
||||||
|
t.Fatalf("failed to drop table: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
for i := 0; i < 2; i++ {
|
||||||
|
t.Run("migrate", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
if err := DB.AutoMigrate(&TestTable{}); err != nil {
|
||||||
|
t.Fatalf("failed to migrate: %v", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user