mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-06-23 08:00:02 +02:00
chore: QoL improvements to tests (#7917)
- Use mock helper functions, instead of home-brew solutions. - Disable cron jobs that are not important to be run during integration tests and might even interfere. - Avoid sleeping unnecessary, if there's some requirement then sleep or retry until that requirement is met. - Avoid trying to deliver webhooks that will always result in a failure. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7917 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
112ba66637
commit
fa2a135f68
44 changed files with 155 additions and 264 deletions
|
@ -585,7 +585,6 @@ func TestPullMergeIndexerNotifier(t *testing.T) {
|
|||
createPullResp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "Indexer notifier test pull")
|
||||
|
||||
require.NoError(t, queue.GetManager().FlushAll(t.Context(), 0))
|
||||
time.Sleep(time.Second)
|
||||
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
|
||||
OwnerName: "user2",
|
||||
|
@ -624,7 +623,6 @@ func TestPullMergeIndexerNotifier(t *testing.T) {
|
|||
assert.True(t, issue.IsClosed)
|
||||
|
||||
require.NoError(t, queue.GetManager().FlushAll(t.Context(), 0))
|
||||
time.Sleep(time.Second)
|
||||
|
||||
// search issues again
|
||||
searchIssuesResp = session.MakeRequest(t, NewRequest(t, "GET", link.String()), http.StatusOK)
|
||||
|
@ -893,8 +891,6 @@ func testPullAutoMergeAfterCommitStatusSucceed(t *testing.T, ctx APITestContext,
|
|||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// approve PR if necessary
|
||||
if approval {
|
||||
// reload PR again
|
||||
|
@ -908,8 +904,6 @@ func testPullAutoMergeAfterCommitStatusSucceed(t *testing.T, ctx APITestContext,
|
|||
resp := approveSession.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
testSubmitReview(t, approveSession, htmlDoc.GetCSRF(), "user2", "repo1", strconv.Itoa(int(pr.Index)), sha, "approve", http.StatusOK)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
// reload PR again
|
||||
|
@ -1090,8 +1084,6 @@ func TestPullAutoMergeAfterCommitStatusSucceedAndApprovalForAgitFlow(t *testing.
|
|||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// reload pr again
|
||||
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
|
||||
assert.False(t, pr.HasMerged)
|
||||
|
@ -1104,8 +1096,6 @@ func TestPullAutoMergeAfterCommitStatusSucceedAndApprovalForAgitFlow(t *testing.
|
|||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
testSubmitReview(t, approveSession, htmlDoc.GetCSRF(), "user2", "repo1", strconv.Itoa(int(pr.Index)), sha, "approve", http.StatusOK)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// realod pr again
|
||||
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
|
||||
assert.True(t, pr.HasMerged)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue