From dfe8cb7bbab06ef26f72e2848122b719308343d1 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 3 Jan 2025 10:55:17 -0800 Subject: [PATCH] Fix tests --- models/fixtures/branch.yml | 3 +++ tests/integration/pull_merge_test.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/models/fixtures/branch.yml b/models/fixtures/branch.yml index 77b0647488..e8dc4c4a28 100644 --- a/models/fixtures/branch.yml +++ b/models/fixtures/branch.yml @@ -112,6 +112,7 @@ commit_message: 'first commit' commit_time: 978307100 pusher_id: 1 + is_deleted: false - id: 18 @@ -121,6 +122,7 @@ commit_message: 'Initial commit' commit_time: 1489956479 pusher_id: 1 + is_deleted: false - id: 19 @@ -140,6 +142,7 @@ commit_message: 'add WoW File' commit_time: 1579200695 pusher_id: 1 + is_deleted: false - id: 21 diff --git a/tests/integration/pull_merge_test.go b/tests/integration/pull_merge_test.go index 2edc95d4c8..0e8729e425 100644 --- a/tests/integration/pull_merge_test.go +++ b/tests/integration/pull_merge_test.go @@ -30,6 +30,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/queue" + repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" @@ -308,7 +309,8 @@ func TestCantMergeUnrelated(t *testing.T) { assert.NoError(t, err) sha := strings.TrimSpace(stdout.String()) - _, _, err = git.NewCommand(git.DefaultContext, "update-index", "--add", "--replace", "--cacheinfo").AddDynamicArguments("100644", sha, "somewher-over-the-rainbow").RunStdString(&git.RunOpts{Dir: path}) + _, _, err = git.NewCommand(git.DefaultContext, "update-index", "--add", "--replace", "--cacheinfo"). + AddDynamicArguments("100644", sha, "somewher-over-the-rainbow").RunStdString(&git.RunOpts{Dir: path}) assert.NoError(t, err) treeSha, _, err := git.NewCommand(git.DefaultContext, "write-tree").RunStdString(&git.RunOpts{Dir: path}) @@ -344,6 +346,10 @@ func TestCantMergeUnrelated(t *testing.T) { _, _, err = git.NewCommand(git.DefaultContext, "branch", "unrelated").AddDynamicArguments(commitSha).RunStdString(&git.RunOpts{Dir: path}) assert.NoError(t, err) + // we created a branch to git repository directly, now we need to do a sync to make it available in the database + _, err = repo_module.SyncRepoBranches(db.DefaultContext, repo1.ID, user1.ID) + assert.NoError(t, err) + testEditFileToNewBranch(t, session, "user1", "repo1", "master", "conflict", "README.md", "Hello, World (Edited Once)\n") // Use API to create a conflicting pr