Skip to content

Commit 583b1b8

Browse files
typelesstechknowlogick
authored andcommitted
Retry test-fixtures loading in case of transaction rollback (#5125)
1 parent 2313121 commit 583b1b8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

models/test_fixtures.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,14 @@ func InitFixtures(helper testfixtures.Helper, dir string) (err error) {
1919

2020
// LoadFixtures load fixtures for a test database
2121
func LoadFixtures() error {
22-
return fixtures.Load()
22+
var err error
23+
// Database transaction conflicts could occur and result in ROLLBACK
24+
// As a simple workaround, we just retry 5 times.
25+
for i := 0; i < 5; i++ {
26+
err = fixtures.Load()
27+
if err == nil {
28+
break
29+
}
30+
}
31+
return err
2332
}

0 commit comments

Comments
 (0)