summaryrefslogtreecommitdiffstats
path: root/tests/integration/api_releases_test.go
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-01-26 17:33:47 +0100
committerGitHub <noreply@github.com>2023-01-26 10:33:47 -0600
commit4d072a4c4e47140550df18edf35d7243ae5edcbd (patch)
treec1bb19442518481494895f6b37cc6604bf8788e8 /tests/integration/api_releases_test.go
parente8ac6a9aeacf0adf21982abc51baa8938e5dd6bb (diff)
downloadgitea-4d072a4c4e47140550df18edf35d7243ae5edcbd.tar.gz
gitea-4d072a4c4e47140550df18edf35d7243ae5edcbd.zip
Add API endpoint to get latest release (#21267)
This PR adds a new API endpoint to get the latest stable release of a repo, similar to [GitHub API](https://docs.github.com/en/rest/releases/releases#get-the-latest-release).
Diffstat (limited to 'tests/integration/api_releases_test.go')
-rw-r--r--tests/integration/api_releases_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go
index d7f2a1b8b1..aa5816ad02 100644
--- a/tests/integration/api_releases_test.go
+++ b/tests/integration/api_releases_test.go
@@ -176,6 +176,24 @@ func TestAPICreateReleaseToDefaultBranchOnExistingTag(t *testing.T) {
createNewReleaseUsingAPI(t, session, token, owner, repo, "v0.0.1", "", "v0.0.1", "test")
}
+func TestAPIGetLatestRelease(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
+
+ urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/releases/latest",
+ owner.Name, repo.Name)
+
+ req := NewRequestf(t, "GET", urlStr)
+ resp := MakeRequest(t, req, http.StatusOK)
+
+ var release *api.Release
+ DecodeJSON(t, resp, &release)
+
+ assert.Equal(t, "testing-release", release.Title)
+}
+
func TestAPIGetReleaseByTag(t *testing.T) {
defer tests.PrepareTestEnv(t)()