@@ -20,6 +20,7 @@ import (
2020	files_service "code.gitea.io/gitea/services/repository/files" 
2121
2222	"github.com/stretchr/testify/assert" 
23+ 	"github.com/stretchr/testify/require" 
2324)
2425
2526func  TestAPIPullUpdate (t  * testing.T ) {
@@ -28,16 +29,16 @@ func TestAPIPullUpdate(t *testing.T) {
2829		user  :=  unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 2 })
2930		org26  :=  unittest .AssertExistsAndLoadBean (t , & user_model.User {ID : 26 })
3031		pr  :=  createOutdatedPR (t , user , org26 )
31- 		assert .NoError (t , pr .LoadBaseRepo (t .Context ()))
32+ 		require .NoError (t , pr .LoadBaseRepo (t .Context ()))
33+ 		require .NoError (t , pr .LoadIssue (t .Context ()))
3234
3335		// Test GetDiverging 
3436		diffCount , err  :=  gitrepo .GetDivergingCommits (t .Context (), pr .BaseRepo , pr .BaseBranch , pr .GetGitHeadRefName ())
35- 		assert .NoError (t , err )
37+ 		require .NoError (t , err )
3638		assert .Equal (t , 1 , diffCount .Behind )
3739		assert .Equal (t , 1 , diffCount .Ahead )
3840		assert .Equal (t , diffCount .Behind , pr .CommitsBehind )
3941		assert .Equal (t , diffCount .Ahead , pr .CommitsAhead )
40- 		assert .NoError (t , pr .LoadIssue (t .Context ()))
4142
4243		session  :=  loginUser (t , "user2" )
4344		token  :=  getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
@@ -47,12 +48,13 @@ func TestAPIPullUpdate(t *testing.T) {
4748
4849		// Test GetDiverging after update 
4950		diffCount , err  =  gitrepo .GetDivergingCommits (t .Context (), pr .BaseRepo , pr .BaseBranch , pr .GetGitHeadRefName ())
50- 		assert .NoError (t , err )
51+ 		require .NoError (t , err )
5152		assert .Equal (t , 0 , diffCount .Behind )
5253		assert .Equal (t , 2 , diffCount .Ahead )
53- 		pr  =  unittest .AssertExistsAndLoadBean (t , & issues_model.PullRequest {ID : pr .ID })
54- 		assert .Equal (t , diffCount .Behind , pr .CommitsBehind )
55- 		assert .Equal (t , diffCount .Ahead , pr .CommitsAhead )
54+ 		assert .Eventually (t , func () bool  {
55+ 			pr  :=  unittest .AssertExistsAndLoadBean (t , & issues_model.PullRequest {ID : pr .ID })
56+ 			return  diffCount .Behind  ==  pr .CommitsBehind  &&  diffCount .Ahead  ==  pr .CommitsAhead 
57+ 		}, 5 * time .Second , 20 * time .Millisecond )
5658	})
5759}
5860
0 commit comments