mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 12:53:57 +01:00
Fix continuance tests (#18027)
This commit is contained in:
parent
d8ae769dda
commit
273bef1be3
3 changed files with 56 additions and 0 deletions
|
@ -278,6 +278,10 @@ func TestAPILFSBatch(t *testing.T) {
|
|||
meta, err = models.GetLFSMetaObjectByOid(repo.ID, p.Oid)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, meta)
|
||||
|
||||
// Cleanup
|
||||
err = contentStore.Delete(p.RelativePath())
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("AlreadyExists", func(t *testing.T) {
|
||||
|
@ -378,6 +382,10 @@ func TestAPILFSUpload(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.NotNil(t, meta)
|
||||
})
|
||||
|
||||
// Cleanup
|
||||
err = contentStore.Delete(p.RelativePath())
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("MetaAlreadyExists", func(t *testing.T) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -68,6 +69,12 @@ func testMirrorPush(t *testing.T, u *url.URL) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, srcCommit.ID, mirrorCommit.ID)
|
||||
|
||||
// Cleanup
|
||||
doRemovePushMirror(ctx, fmt.Sprintf("%s%s/%s", u.String(), url.PathEscape(ctx.Username), url.PathEscape(mirrorRepo.Name)), user.LowerName, userPassword, int(mirrors[0].ID))(t)
|
||||
mirrors, err = repo_model.GetPushMirrorsByRepoID(srcRepo.ID)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, mirrors, 0)
|
||||
}
|
||||
|
||||
func doCreatePushMirror(ctx APITestContext, address, username, password string) func(t *testing.T) {
|
||||
|
@ -89,3 +96,24 @@ func doCreatePushMirror(ctx APITestContext, address, username, password string)
|
|||
assert.Contains(t, flashCookie.Value, "success")
|
||||
}
|
||||
}
|
||||
|
||||
func doRemovePushMirror(ctx APITestContext, address, username, password string, pushMirrorID int) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
csrf := GetCSRF(t, ctx.Session, fmt.Sprintf("/%s/%s/settings", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)))
|
||||
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)), map[string]string{
|
||||
"_csrf": csrf,
|
||||
"action": "push-mirror-remove",
|
||||
"push_mirror_id": strconv.Itoa(pushMirrorID),
|
||||
"push_mirror_address": address,
|
||||
"push_mirror_username": username,
|
||||
"push_mirror_password": password,
|
||||
"push_mirror_interval": "0",
|
||||
})
|
||||
ctx.Session.MakeRequest(t, req, http.StatusFound)
|
||||
|
||||
flashCookie := ctx.Session.GetCookie("macaron_flash")
|
||||
assert.NotNil(t, flashCookie)
|
||||
assert.Contains(t, flashCookie.Value, "success")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,4 +74,24 @@ func TestCreateNewTagProtected(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "Tag v-2 is protected")
|
||||
})
|
||||
})
|
||||
|
||||
// Cleanup
|
||||
releases, err := models.GetReleasesByRepoID(repo.ID, models.FindReleasesOptions{
|
||||
IncludeTags: true,
|
||||
TagNames: []string{"v-1", "v-1.1"},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
for _, release := range releases {
|
||||
err = models.DeleteReleaseByID(release.ID)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
protectedTags, err := models.GetProtectedTags(repo.ID)
|
||||
assert.NoError(t, err)
|
||||
|
||||
for _, protectedTag := range protectedTags {
|
||||
err = models.DeleteProtectedTag(protectedTag)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue