summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_releases_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/integrations/api_releases_test.go b/integrations/api_releases_test.go
index 9aef33d068..58c2e35440 100644
--- a/integrations/api_releases_test.go
+++ b/integrations/api_releases_test.go
@@ -7,6 +7,7 @@ package integrations
import (
"fmt"
"net/http"
+ "strings"
"testing"
"code.gitea.io/gitea/models"
@@ -120,3 +121,36 @@ func TestAPICreateReleaseToDefaultBranchOnExistingTag(t *testing.T) {
createNewReleaseUsingAPI(t, session, token, owner, repo, "v0.0.1", "", "v0.0.1", "test")
}
+
+func TestAPIGetReleaseByTag(t *testing.T) {
+ defer prepareTestEnv(t)()
+
+ repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
+ owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
+ session := loginUser(t, owner.LowerName)
+
+ tag := "v1.1"
+
+ urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/%s/",
+ owner.Name, repo.Name, tag)
+
+ req := NewRequestf(t, "GET", urlStr)
+ resp := session.MakeRequest(t, req, http.StatusOK)
+
+ var release *api.Release
+ DecodeJSON(t, resp, &release)
+
+ assert.Equal(t, "testing-release", release.Title)
+
+ nonexistingtag := "nonexistingtag"
+
+ urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/%s/",
+ owner.Name, repo.Name, nonexistingtag)
+
+ req = NewRequestf(t, "GET", urlStr)
+ resp = session.MakeRequest(t, req, http.StatusNotFound)
+
+ var err *api.APIError
+ DecodeJSON(t, resp, &err)
+ assert.True(t, strings.HasPrefix(err.Message, "release tag does not exist"))
+}