Skip to content

Commit 273bef1

Browse files
author
Gusted
authored
Fix continuance tests (#18027)
1 parent d8ae769 commit 273bef1

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

integrations/api_repo_lfs_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ func TestAPILFSBatch(t *testing.T) {
278278
meta, err = models.GetLFSMetaObjectByOid(repo.ID, p.Oid)
279279
assert.NoError(t, err)
280280
assert.NotNil(t, meta)
281+
282+
// Cleanup
283+
err = contentStore.Delete(p.RelativePath())
284+
assert.NoError(t, err)
281285
})
282286

283287
t.Run("AlreadyExists", func(t *testing.T) {
@@ -378,6 +382,10 @@ func TestAPILFSUpload(t *testing.T) {
378382
assert.NoError(t, err)
379383
assert.NotNil(t, meta)
380384
})
385+
386+
// Cleanup
387+
err = contentStore.Delete(p.RelativePath())
388+
assert.NoError(t, err)
381389
})
382390

383391
t.Run("MetaAlreadyExists", func(t *testing.T) {

integrations/mirror_push_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"net/http"
1111
"net/url"
12+
"strconv"
1213
"testing"
1314

1415
"code.gitea.io/gitea/models"
@@ -68,6 +69,12 @@ func testMirrorPush(t *testing.T, u *url.URL) {
6869
assert.NoError(t, err)
6970

7071
assert.Equal(t, srcCommit.ID, mirrorCommit.ID)
72+
73+
// Cleanup
74+
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)
75+
mirrors, err = repo_model.GetPushMirrorsByRepoID(srcRepo.ID)
76+
assert.NoError(t, err)
77+
assert.Len(t, mirrors, 0)
7178
}
7279

7380
func doCreatePushMirror(ctx APITestContext, address, username, password string) func(t *testing.T) {
@@ -89,3 +96,24 @@ func doCreatePushMirror(ctx APITestContext, address, username, password string)
8996
assert.Contains(t, flashCookie.Value, "success")
9097
}
9198
}
99+
100+
func doRemovePushMirror(ctx APITestContext, address, username, password string, pushMirrorID int) func(t *testing.T) {
101+
return func(t *testing.T) {
102+
csrf := GetCSRF(t, ctx.Session, fmt.Sprintf("/%s/%s/settings", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)))
103+
104+
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)), map[string]string{
105+
"_csrf": csrf,
106+
"action": "push-mirror-remove",
107+
"push_mirror_id": strconv.Itoa(pushMirrorID),
108+
"push_mirror_address": address,
109+
"push_mirror_username": username,
110+
"push_mirror_password": password,
111+
"push_mirror_interval": "0",
112+
})
113+
ctx.Session.MakeRequest(t, req, http.StatusFound)
114+
115+
flashCookie := ctx.Session.GetCookie("macaron_flash")
116+
assert.NotNil(t, flashCookie)
117+
assert.Contains(t, flashCookie.Value, "success")
118+
}
119+
}

integrations/repo_tag_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,24 @@ func TestCreateNewTagProtected(t *testing.T) {
7474
assert.Contains(t, err.Error(), "Tag v-2 is protected")
7575
})
7676
})
77+
78+
// Cleanup
79+
releases, err := models.GetReleasesByRepoID(repo.ID, models.FindReleasesOptions{
80+
IncludeTags: true,
81+
TagNames: []string{"v-1", "v-1.1"},
82+
})
83+
assert.NoError(t, err)
84+
85+
for _, release := range releases {
86+
err = models.DeleteReleaseByID(release.ID)
87+
assert.NoError(t, err)
88+
}
89+
90+
protectedTags, err := models.GetProtectedTags(repo.ID)
91+
assert.NoError(t, err)
92+
93+
for _, protectedTag := range protectedTags {
94+
err = models.DeleteProtectedTag(protectedTag)
95+
assert.NoError(t, err)
96+
}
7797
}

0 commit comments

Comments
 (0)