mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-26 02:50:54 +00:00
Make the PushCreate test declarative (#11229)
Reduce the code duplication in the PushCreate test and switch to a declarative format. * Instead of explicitly creating the repository re-use functions from the other declarative tests and add comments * Ensure that the test repository is deleted at the end of test * Slightly reorder the sub-tests Also reduce the code duplication in MergeFork and add some comments there too and make doGitCloneFail be self-contained. Signed-off-by: Andrew Thornton art27@cantab.net
This commit is contained in:
parent
b0849abf3d
commit
1f0b797ddc
3 changed files with 72 additions and 102 deletions
|
@ -113,7 +113,7 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
|
|||
|
||||
sshURL := createSSHUrl(ctx.GitPath(), u)
|
||||
|
||||
t.Run("FailToClone", doGitCloneFail(dstPath, sshURL))
|
||||
t.Run("FailToClone", doGitCloneFail(sshURL))
|
||||
|
||||
t.Run("CreateUserKey", doAPICreateUserKey(ctx, keyname, keyFile, func(t *testing.T, publicKey api.PublicKey) {
|
||||
userKeyPublicKeyID = publicKey.ID
|
||||
|
@ -139,7 +139,7 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
|
|||
|
||||
sshURL := createSSHUrl(ctx.GitPath(), u)
|
||||
|
||||
t.Run("FailToClone", doGitCloneFail(dstPath, sshURL))
|
||||
t.Run("FailToClone", doGitCloneFail(sshURL))
|
||||
|
||||
// Should now be able to add...
|
||||
t.Run("AddReadOnlyDeployKey", doAPICreateDeployKey(ctx, keyname, keyFile, true))
|
||||
|
@ -204,15 +204,11 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
|
|||
})
|
||||
|
||||
t.Run("DeleteUserKeyShouldRemoveAbilityToClone", func(t *testing.T) {
|
||||
dstPath, err := ioutil.TempDir("", ctx.Reponame)
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(dstPath)
|
||||
|
||||
sshURL := createSSHUrl(ctx.GitPath(), u)
|
||||
|
||||
t.Run("DeleteUserKey", doAPIDeleteUserKey(ctx, userKeyPublicKeyID))
|
||||
|
||||
t.Run("FailToClone", doGitCloneFail(dstPath, sshURL))
|
||||
t.Run("FailToClone", doGitCloneFail(sshURL))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue