|
|
@ -154,7 +154,7 @@ func TestAPIGetReleaseByTag(t *testing.T) { |
|
|
|
assert.EqualValues(t, "Not Found", err.Message) |
|
|
|
assert.EqualValues(t, "Not Found", err.Message) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAPIDeleteTagByName(t *testing.T) { |
|
|
|
func TestAPIDeleteReleaseByTagName(t *testing.T) { |
|
|
|
defer prepareTestEnv(t)() |
|
|
|
defer prepareTestEnv(t)() |
|
|
|
|
|
|
|
|
|
|
|
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) |
|
|
|
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) |
|
|
@ -162,17 +162,17 @@ func TestAPIDeleteTagByName(t *testing.T) { |
|
|
|
session := loginUser(t, owner.LowerName) |
|
|
|
session := loginUser(t, owner.LowerName) |
|
|
|
token := getTokenForLoggedInUser(t, session) |
|
|
|
token := getTokenForLoggedInUser(t, session) |
|
|
|
|
|
|
|
|
|
|
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/delete-tag?token=%s", |
|
|
|
createNewReleaseUsingAPI(t, session, token, owner, repo, "release-tag", "", "Release Tag", "test") |
|
|
|
owner.Name, repo.Name, token) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req := NewRequestf(t, http.MethodDelete, urlStr) |
|
|
|
// delete release
|
|
|
|
|
|
|
|
req := NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag?token=%s", owner.Name, repo.Name, token)) |
|
|
|
_ = session.MakeRequest(t, req, http.StatusNoContent) |
|
|
|
_ = session.MakeRequest(t, req, http.StatusNoContent) |
|
|
|
|
|
|
|
|
|
|
|
// Make sure that actual releases can't be deleted outright
|
|
|
|
// make sure release is deleted
|
|
|
|
createNewReleaseUsingAPI(t, session, token, owner, repo, "release-tag", "", "Release Tag", "test") |
|
|
|
req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag?token=%s", owner.Name, repo.Name, token)) |
|
|
|
urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag?token=%s", |
|
|
|
_ = session.MakeRequest(t, req, http.StatusNotFound) |
|
|
|
owner.Name, repo.Name, token) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = NewRequestf(t, http.MethodDelete, urlStr) |
|
|
|
// delete release tag too
|
|
|
|
_ = session.MakeRequest(t, req, http.StatusConflict) |
|
|
|
req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/tags/release-tag?token=%s", owner.Name, repo.Name, token)) |
|
|
|
|
|
|
|
_ = session.MakeRequest(t, req, http.StatusNoContent) |
|
|
|
} |
|
|
|
} |
|
|
|