diff options
author | Mura Li <typeless@users.noreply.github.com> | 2018-10-21 04:48:33 +0800 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-10-20 16:48:33 -0400 |
commit | 583b1b84293635633199123ff759849fbd09f7f2 (patch) | |
tree | c4319bec10c37e23a4f0eb26b6441bf228e32c1b /models/test_fixtures.go | |
parent | 2313121354ae2c02c73d654e9d6827904f75b469 (diff) | |
download | gitea-583b1b84293635633199123ff759849fbd09f7f2.tar.gz gitea-583b1b84293635633199123ff759849fbd09f7f2.zip |
Retry test-fixtures loading in case of transaction rollback (#5125)
Diffstat (limited to 'models/test_fixtures.go')
-rw-r--r-- | models/test_fixtures.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/models/test_fixtures.go b/models/test_fixtures.go index d7f59ec3b5..2a70bc9816 100644 --- a/models/test_fixtures.go +++ b/models/test_fixtures.go @@ -19,5 +19,14 @@ func InitFixtures(helper testfixtures.Helper, dir string) (err error) { // LoadFixtures load fixtures for a test database 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 } |