Fix tests

This commit is contained in:
Lunny Xiao 2025-01-03 10:55:17 -08:00
parent 453adc24d4
commit dfe8cb7bba
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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