mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Retry test-fixtures loading in case of transaction rollback (#5125)
This commit is contained in:
		@@ -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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user