Merge pull request 'test: even more sha256 repositories tests' (#3856) from oliverpool/forgejo:push_create_sha256 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3856 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
7bd8443739
1 changed files with 74 additions and 67 deletions
|
@ -56,15 +56,16 @@ func testGit(t *testing.T, u *url.URL) {
|
|||
forkedUserCtx := NewAPITestContext(t, "user4", "repo1", auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
|
||||
|
||||
t.Run("HTTP", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
ensureAnonymousClone(t, u)
|
||||
forEachObjectFormat(t, func(t *testing.T, objectFormat git.ObjectFormat) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
httpContext := baseAPITestContext
|
||||
httpContext.Reponame = "repo-tmp-17"
|
||||
httpContext.Reponame = "repo-tmp-17-" + objectFormat.Name()
|
||||
forkedUserCtx.Reponame = httpContext.Reponame
|
||||
|
||||
dstPath := t.TempDir()
|
||||
|
||||
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, git.Sha1ObjectFormat)) // FIXME: use forEachObjectFormat
|
||||
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, objectFormat))
|
||||
t.Run("AddUserAsCollaborator", doAPIAddCollaborator(forkedUserCtx, httpContext.Username, perm.AccessModeRead))
|
||||
|
||||
t.Run("ForkFromDifferentUser", doAPIForkRepository(httpContext, forkedUserCtx.Username))
|
||||
|
@ -95,21 +96,23 @@ func testGit(t *testing.T, u *url.URL) {
|
|||
mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS)
|
||||
})
|
||||
|
||||
t.Run("PushCreate", doPushCreate(httpContext, u))
|
||||
t.Run("PushCreate", doPushCreate(httpContext, u, objectFormat))
|
||||
})
|
||||
})
|
||||
t.Run("SSH", func(t *testing.T) {
|
||||
forEachObjectFormat(t, func(t *testing.T, objectFormat git.ObjectFormat) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
sshContext := baseAPITestContext
|
||||
sshContext.Reponame = "repo-tmp-18"
|
||||
sshContext.Reponame = "repo-tmp-18-" + objectFormat.Name()
|
||||
keyname := "my-testing-key"
|
||||
forkedUserCtx.Reponame = sshContext.Reponame
|
||||
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, git.Sha1ObjectFormat)) // FIXME: use forEachObjectFormat
|
||||
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, objectFormat))
|
||||
t.Run("AddUserAsCollaborator", doAPIAddCollaborator(forkedUserCtx, sshContext.Username, perm.AccessModeRead))
|
||||
t.Run("ForkFromDifferentUser", doAPIForkRepository(sshContext, forkedUserCtx.Username))
|
||||
|
||||
// Setup key the user ssh key
|
||||
withKeyFile(t, keyname, func(keyFile string) {
|
||||
t.Run("CreateUserKey", doAPICreateUserKey(sshContext, "test-key", keyFile))
|
||||
t.Run("CreateUserKey", doAPICreateUserKey(sshContext, "test-key-"+objectFormat.Name(), keyFile))
|
||||
|
||||
// Setup remote link
|
||||
// TODO: get url from api
|
||||
|
@ -135,7 +138,8 @@ func testGit(t *testing.T, u *url.URL) {
|
|||
mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS)
|
||||
})
|
||||
|
||||
t.Run("PushCreate", doPushCreate(sshContext, sshURL))
|
||||
t.Run("PushCreate", doPushCreate(sshContext, sshURL, objectFormat))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -586,8 +590,11 @@ func doEnsureDiffNoChange(ctx APITestContext, pr api.PullRequest, diffHash strin
|
|||
}
|
||||
}
|
||||
|
||||
func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
|
||||
func doPushCreate(ctx APITestContext, u *url.URL, objectFormat git.ObjectFormat) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
if objectFormat == git.Sha256ObjectFormat {
|
||||
t.Skipf("push-create not supported for %s, see https://codeberg.org/forgejo/forgejo/issues/3783", objectFormat)
|
||||
}
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
|
||||
// create a context for a currently non-existent repository
|
||||
|
@ -598,7 +605,7 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
|
|||
tmpDir := t.TempDir()
|
||||
|
||||
// Now create local repository to push as our test and set its origin
|
||||
t.Run("InitTestRepository", doGitInitTestRepository(tmpDir, git.Sha1ObjectFormat)) // FIXME: use forEachObjectFormat
|
||||
t.Run("InitTestRepository", doGitInitTestRepository(tmpDir, objectFormat))
|
||||
t.Run("AddRemote", doGitAddRemote(tmpDir, "origin", u))
|
||||
|
||||
// Disable "Push To Create" and attempt to push
|
||||
|
|
Loading…
Reference in a new issue