mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-13 14:27:17 +00:00
chore: unbreak existing tests
Because the user:password is no longer automatically set as upstream origin, we have to set it manually if we want push to work.
This commit is contained in:
parent
9fb75a141d
commit
f7fb1226a4
5 changed files with 16 additions and 0 deletions
|
@ -47,6 +47,7 @@ func CodeOwnerTestCommon(t *testing.T, u *url.URL, codeownerTest CodeownerTest)
|
||||||
cloneURL, _ := url.Parse(r)
|
cloneURL, _ := url.Parse(r)
|
||||||
cloneURL.User = url.UserPassword("user2", userPassword)
|
cloneURL.User = url.UserPassword("user2", userPassword)
|
||||||
require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
|
require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
|
||||||
|
doGitSetRemoteURL(dstPath, "origin", cloneURL)(t)
|
||||||
|
|
||||||
t.Run("Normal", func(t *testing.T) {
|
t.Run("Normal", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
|
@ -105,6 +105,8 @@ func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
|
||||||
exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
|
exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.True(t, exist)
|
assert.True(t, exist)
|
||||||
|
// Set user:password
|
||||||
|
doGitSetRemoteURL(dstLocalPath, "origin", u)(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +119,8 @@ func doPartialGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
|
||||||
exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
|
exist, err := util.IsExist(filepath.Join(dstLocalPath, "README.md"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.True(t, exist)
|
assert.True(t, exist)
|
||||||
|
// Set user:password
|
||||||
|
doGitSetRemoteURL(dstLocalPath, "origin", u)(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +166,14 @@ func doGitAddRemote(dstPath, remoteName string, u *url.URL) func(*testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doGitSetRemoteURL(dstPath, remoteName string, u *url.URL) func(*testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
_, _, err := git.NewCommand(git.DefaultContext, "remote", "set-url").AddDynamicArguments(remoteName, u.String()).RunStdString(&git.RunOpts{Dir: dstPath})
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func doGitPushTestRepository(dstPath string, args ...string) func(*testing.T) {
|
func doGitPushTestRepository(dstPath string, args ...string) func(*testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
|
@ -78,6 +78,7 @@ func TestPatchStatus(t *testing.T) {
|
||||||
// Clone repository.
|
// Clone repository.
|
||||||
dstPath := t.TempDir()
|
dstPath := t.TempDir()
|
||||||
require.NoError(t, git.Clone(t.Context(), u.String(), dstPath, git.CloneRepoOptions{}))
|
require.NoError(t, git.Clone(t.Context(), u.String(), dstPath, git.CloneRepoOptions{}))
|
||||||
|
doGitSetRemoteURL(dstPath, "origin", u)(t)
|
||||||
|
|
||||||
// Add `fork` remote.
|
// Add `fork` remote.
|
||||||
u.Path = forkRepo.FullName()
|
u.Path = forkRepo.FullName()
|
||||||
|
|
|
@ -93,6 +93,7 @@ func TestPullDiff_AGitNotEditable(t *testing.T) {
|
||||||
cloneURL, _ := url.Parse(clone)
|
cloneURL, _ := url.Parse(clone)
|
||||||
cloneURL.User = url.UserPassword("user2", userPassword)
|
cloneURL.User = url.UserPassword("user2", userPassword)
|
||||||
require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
|
require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
|
||||||
|
doGitSetRemoteURL(dstPath, "origin", cloneURL)(t)
|
||||||
|
|
||||||
return dstPath
|
return dstPath
|
||||||
}
|
}
|
||||||
|
|
|
@ -791,6 +791,7 @@ func TestPullRequestStaleReview(t *testing.T) {
|
||||||
cloneURL, _ := url.Parse(clone)
|
cloneURL, _ := url.Parse(clone)
|
||||||
cloneURL.User = url.UserPassword("user2", userPassword)
|
cloneURL.User = url.UserPassword("user2", userPassword)
|
||||||
require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
|
require.NoError(t, git.CloneWithArgs(t.Context(), nil, cloneURL.String(), dstPath, git.CloneRepoOptions{}))
|
||||||
|
doGitSetRemoteURL(dstPath, "origin", cloneURL)(t)
|
||||||
|
|
||||||
return dstPath
|
return dstPath
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue