Browse Source

Retry test-fixtures loading in case of transaction rollback (#5125)

for-closed-social
Mura Li 6 years ago
committed by techknowlogick
parent
commit
583b1b8429
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      models/test_fixtures.go

+ 10
- 1
models/test_fixtures.go View File

@ -19,5 +19,14 @@ func InitFixtures(helper testfixtures.Helper, dir string) (err error) {
// LoadFixtures load fixtures for a test database // LoadFixtures load fixtures for a test database
func LoadFixtures() error { func LoadFixtures() error {
return fixtures.Load()
var err error
// Database transaction conflicts could occur and result in ROLLBACK
// As a simple workaround, we just retry 5 times.
for i := 0; i < 5; i++ {
err = fixtures.Load()
if err == nil {
break
}
}
return err
} }

Loading…
Cancel
Save