[TESTS] Convert more tests to CreateDeclarativeRepo

These tests originate from Gitea, so may cause conflicts in the longer
run. But they use the same pattern, so transitioning them to the helper
is hopefully a benefit that offsets the risk.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 2d475af49484bd428018e479fa35643f61a30426)
(cherry picked from commit a99c17729c635398d3722da9da7d9cbe2b47c533)
This commit is contained in:
Gergely Nagy 2024-01-12 11:53:14 +01:00 committed by Earl Warren
parent 48d752c630
commit fdda432d1e
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 17 additions and 88 deletions

View file

@ -82,17 +82,7 @@ func TestAPIPullUpdateByRebase(t *testing.T) {
}
func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_model.PullRequest {
baseRepo, err := repo_service.CreateRepository(db.DefaultContext, actor, actor, repo_service.CreateRepoOptions{
Name: "repo-pr-update",
Description: "repo-tmp-pr-update description",
AutoInit: true,
Gitignores: "C,C++",
License: "MIT",
Readme: "Default",
IsPrivate: false,
})
assert.NoError(t, err)
assert.NotEmpty(t, baseRepo)
baseRepo, _, _ := CreateDeclarativeRepo(t, actor, "repo-pr-update", nil, nil, nil)
headRepo, err := repo_service.ForkRepository(git.DefaultContext, actor, forkOrg, repo_service.ForkRepoOptions{
BaseRepo: baseRepo,
@ -112,8 +102,8 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_mod
},
},
Message: "Add File A",
OldBranch: "master",
NewBranch: "master",
OldBranch: "main",
NewBranch: "main",
Author: &files_service.IdentityOptions{
Name: actor.Name,
Email: actor.Email,
@ -139,7 +129,7 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_mod
},
},
Message: "Add File on PR branch",
OldBranch: "master",
OldBranch: "main",
NewBranch: "newBranch",
Author: &files_service.IdentityOptions{
Name: actor.Name,
@ -168,7 +158,7 @@ func createOutdatedPR(t *testing.T, actor, forkOrg *user_model.User) *issues_mod
HeadRepoID: headRepo.ID,
BaseRepoID: baseRepo.ID,
HeadBranch: "newBranch",
BaseBranch: "master",
BaseBranch: "main",
HeadRepo: headRepo,
BaseRepo: baseRepo,
Type: issues_model.PullRequestGitea,