summaryrefslogtreecommitdiffstats
path: root/tests/integration/api_issue_label_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-02 11:39:42 +0800
committerGitHub <noreply@github.com>2022-12-01 22:39:42 -0500
commitdf676a47d05b20f7bfe4fdae350f50af15b52905 (patch)
treedc747e21fd2a533aeacb1686f747bba0a8f60736 /tests/integration/api_issue_label_test.go
parent665d02efaf6ebaadf3ffb5b412ea77c4502f0baf (diff)
downloadgitea-df676a47d05b20f7bfe4fdae350f50af15b52905.tar.gz
gitea-df676a47d05b20f7bfe4fdae350f50af15b52905.zip
Remove session in api tests (#21984)
It's no meaning to request an API route with session.
Diffstat (limited to 'tests/integration/api_issue_label_test.go')
-rw-r--r--tests/integration/api_issue_label_test.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/integration/api_issue_label_test.go b/tests/integration/api_issue_label_test.go
index 8a324a6684..6f0fd87913 100644
--- a/tests/integration/api_issue_label_test.go
+++ b/tests/integration/api_issue_label_test.go
@@ -33,7 +33,7 @@ func TestAPIModifyLabels(t *testing.T) {
Color: "abcdef",
Description: "test label",
})
- resp := session.MakeRequest(t, req, http.StatusCreated)
+ resp := MakeRequest(t, req, http.StatusCreated)
apiLabel := new(api.Label)
DecodeJSON(t, resp, &apiLabel)
dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, RepoID: repo.ID})
@@ -45,16 +45,16 @@ func TestAPIModifyLabels(t *testing.T) {
Color: "#123456",
Description: "jet another test label",
})
- session.MakeRequest(t, req, http.StatusCreated)
+ MakeRequest(t, req, http.StatusCreated)
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{
Name: "WrongTestL",
Color: "#12345g",
})
- session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+ MakeRequest(t, req, http.StatusUnprocessableEntity)
// ListLabels
req = NewRequest(t, "GET", urlStr)
- resp = session.MakeRequest(t, req, http.StatusOK)
+ resp = MakeRequest(t, req, http.StatusOK)
var apiLabels []*api.Label
DecodeJSON(t, resp, &apiLabels)
assert.Len(t, apiLabels, 2)
@@ -62,7 +62,7 @@ func TestAPIModifyLabels(t *testing.T) {
// GetLabel
singleURLStr := fmt.Sprintf("/api/v1/repos/%s/%s/labels/%d?token=%s", owner.Name, repo.Name, dbLabel.ID, token)
req = NewRequest(t, "GET", singleURLStr)
- resp = session.MakeRequest(t, req, http.StatusOK)
+ resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiLabel)
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
@@ -74,17 +74,17 @@ func TestAPIModifyLabels(t *testing.T) {
Name: &newName,
Color: &newColor,
})
- resp = session.MakeRequest(t, req, http.StatusOK)
+ resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiLabel)
assert.EqualValues(t, newColor, apiLabel.Color)
req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{
Color: &newColorWrong,
})
- session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+ MakeRequest(t, req, http.StatusUnprocessableEntity)
// DeleteLabel
req = NewRequest(t, "DELETE", singleURLStr)
- session.MakeRequest(t, req, http.StatusNoContent)
+ MakeRequest(t, req, http.StatusNoContent)
}
func TestAPIAddIssueLabels(t *testing.T) {
@@ -102,7 +102,7 @@ func TestAPIAddIssueLabels(t *testing.T) {
req := NewRequestWithJSON(t, "POST", urlStr, &api.IssueLabelsOption{
Labels: []int64{1, 2},
})
- resp := session.MakeRequest(t, req, http.StatusOK)
+ resp := MakeRequest(t, req, http.StatusOK)
var apiLabels []*api.Label
DecodeJSON(t, resp, &apiLabels)
assert.Len(t, apiLabels, unittest.GetCount(t, &issues_model.IssueLabel{IssueID: issue.ID}))
@@ -125,7 +125,7 @@ func TestAPIReplaceIssueLabels(t *testing.T) {
req := NewRequestWithJSON(t, "PUT", urlStr, &api.IssueLabelsOption{
Labels: []int64{label.ID},
})
- resp := session.MakeRequest(t, req, http.StatusOK)
+ resp := MakeRequest(t, req, http.StatusOK)
var apiLabels []*api.Label
DecodeJSON(t, resp, &apiLabels)
if assert.Len(t, apiLabels, 1) {
@@ -152,7 +152,7 @@ func TestAPIModifyOrgLabels(t *testing.T) {
Color: "abcdef",
Description: "test label",
})
- resp := session.MakeRequest(t, req, http.StatusCreated)
+ resp := MakeRequest(t, req, http.StatusCreated)
apiLabel := new(api.Label)
DecodeJSON(t, resp, &apiLabel)
dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, OrgID: owner.ID})
@@ -164,16 +164,16 @@ func TestAPIModifyOrgLabels(t *testing.T) {
Color: "#123456",
Description: "jet another test label",
})
- session.MakeRequest(t, req, http.StatusCreated)
+ MakeRequest(t, req, http.StatusCreated)
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{
Name: "WrongTestL",
Color: "#12345g",
})
- session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+ MakeRequest(t, req, http.StatusUnprocessableEntity)
// ListLabels
req = NewRequest(t, "GET", urlStr)
- resp = session.MakeRequest(t, req, http.StatusOK)
+ resp = MakeRequest(t, req, http.StatusOK)
var apiLabels []*api.Label
DecodeJSON(t, resp, &apiLabels)
assert.Len(t, apiLabels, 4)
@@ -181,7 +181,7 @@ func TestAPIModifyOrgLabels(t *testing.T) {
// GetLabel
singleURLStr := fmt.Sprintf("/api/v1/orgs/%s/labels/%d?token=%s", owner.Name, dbLabel.ID, token)
req = NewRequest(t, "GET", singleURLStr)
- resp = session.MakeRequest(t, req, http.StatusOK)
+ resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiLabel)
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
@@ -193,15 +193,15 @@ func TestAPIModifyOrgLabels(t *testing.T) {
Name: &newName,
Color: &newColor,
})
- resp = session.MakeRequest(t, req, http.StatusOK)
+ resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiLabel)
assert.EqualValues(t, newColor, apiLabel.Color)
req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{
Color: &newColorWrong,
})
- session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+ MakeRequest(t, req, http.StatusUnprocessableEntity)
// DeleteLabel
req = NewRequest(t, "DELETE", singleURLStr)
- session.MakeRequest(t, req, http.StatusNoContent)
+ MakeRequest(t, req, http.StatusNoContent)
}