aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-12-21 04:12:27 +0100
committerGitHub <noreply@github.com>2021-12-20 22:12:27 -0500
commit273bef1be3e7512c90ff5cc60cd3b633ce1762b7 (patch)
tree73938a33db3c0ef9b5cbfce5d1b446408d48df2b
parentd8ae769ddaa46100dc4a21e8af159c6a0c091cd2 (diff)
downloadgitea-273bef1be3e7512c90ff5cc60cd3b633ce1762b7.tar.gz
gitea-273bef1be3e7512c90ff5cc60cd3b633ce1762b7.zip
Fix continuance tests (#18027)
-rw-r--r--integrations/api_repo_lfs_test.go8
-rw-r--r--integrations/mirror_push_test.go28
-rw-r--r--integrations/repo_tag_test.go20
3 files changed, 56 insertions, 0 deletions
diff --git a/integrations/api_repo_lfs_test.go b/integrations/api_repo_lfs_test.go
index 26f7e50f5b..947d157d5b 100644
--- a/integrations/api_repo_lfs_test.go
+++ b/integrations/api_repo_lfs_test.go
@@ -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) {
diff --git a/integrations/mirror_push_test.go b/integrations/mirror_push_test.go
index c8b73880ee..b231b7a919 100644
--- a/integrations/mirror_push_test.go
+++ b/integrations/mirror_push_test.go
@@ -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")
+ }
+}
diff --git a/integrations/repo_tag_test.go b/integrations/repo_tag_test.go
index b90dcf0585..4c06044c6e 100644
--- a/integrations/repo_tag_test.go
+++ b/integrations/repo_tag_test.go
@@ -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)
+ }
}