Skip to content

Fix continuance tests #18027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions integrations/api_repo_lfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
28 changes: 28 additions & 0 deletions integrations/mirror_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"testing"

"code.gitea.io/gitea/models"
Expand Down Expand Up @@ -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) {
Expand All @@ -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")
}
}
20 changes: 20 additions & 0 deletions integrations/repo_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}