diff options
author | JakobDev | 2023-01-26 17:33:47 +0100 |
---|---|---|
committer | GitHub | 2023-01-26 10:33:47 -0600 |
commit | 4d072a4c4e47140550df18edf35d7243ae5edcbd (patch) | |
tree | c1bb19442518481494895f6b37cc6604bf8788e8 /tests | |
parent | e8ac6a9aeacf0adf21982abc51baa8938e5dd6bb (diff) |
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')
-rw-r--r-- | tests/integration/api_releases_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index d7f2a1b8b..aa5816ad0 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)() |