diff --git a/pkg/provider/gitea_test.go b/pkg/provider/gitea_test.go index f3e644d..0d8ba2f 100644 --- a/pkg/provider/gitea_test.go +++ b/pkg/provider/gitea_test.go @@ -152,6 +152,30 @@ func TestGiteaCreateReleaseStripPrefix(t *testing.T) { assertions.NoError(err) } +func TestGiteaInvalidTag(t *testing.T) { + setup() + defer teardown() + + assertions := require.New(t) + repo := &GiteaRepository{} + + err := repo.Init(map[string]string{ + "gitea_host": server.URL, + "slug": fmt.Sprintf("%s/%s", giteaUser, giteaRepo), + "token": "token", + }) + + assertions.NoError(err) + + err = repo.CreateRelease(&provider.CreateReleaseConfig{ + NewVersion: "1.0.1", + Prerelease: false, + Branch: "", + SHA: testSHA, + }) + assertions.Errorf(err, "invalid tag name") +} + func TestGiteaEnvironmentVars(t *testing.T) { setup() defer teardown() diff --git a/pkg/provider/test_server.go b/pkg/provider/test_server.go index d3ab396..e50e9bc 100644 --- a/pkg/provider/test_server.go +++ b/pkg/provider/test_server.go @@ -1,3 +1,4 @@ +//coverage:ignore package provider import ( @@ -35,12 +36,6 @@ func CreateTestServer() *httptest.Server { //gocyclo:ignore func GiteaHandler(w http.ResponseWriter, r *http.Request) { - // Rate Limit headers - if r.Header.Get("Authorization") == "" { - http.Error(w, "unauthorized", http.StatusUnauthorized) - return - } - if r.Method == http.MethodGet && r.URL.Path == "/api/v1/version" { // Client performs a request to check version // Get json string from file @@ -88,3 +83,22 @@ func GiteaHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, "invalid route", http.StatusNotImplemented) } + +func GiteaHandlerFailed(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodGet && r.URL.Path == "/api/v1/version" { + // Client performs a request to check version + // Get json string from file + data, _ := retrieveData("data/Version.json") + _, _ = fmt.Fprint(w, string(data)) + return + } + + if r.Method == http.MethodGet && r.URL.Path == fmt.Sprintf("/api/v1/repos/%s/%s", giteaUser, giteaRepo) { + // Get json string from file + data, _ := retrieveData("data/GetRepoInfo.json") + _, _ = fmt.Fprint(w, string(data)) + return + } + + http.Error(w, "invalid route", http.StatusNotImplemented) +}