forked from Shiloh/githaven
Remove unnecessary variable assignments (#17695)
* Remove unnecessary variable assignments As title * enable ineffassign Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
b01f6c1a8c
commit
c98dd7a3e0
@ -15,6 +15,7 @@ linters:
|
|||||||
- misspell
|
- misspell
|
||||||
- gocritic
|
- gocritic
|
||||||
- bidichk
|
- bidichk
|
||||||
|
- ineffassign
|
||||||
enable-all: false
|
enable-all: false
|
||||||
disable-all: true
|
disable-all: true
|
||||||
fast: false
|
fast: false
|
||||||
|
@ -293,7 +293,6 @@ Gitea or set your environment appropriately.`, "")
|
|||||||
}
|
}
|
||||||
} else if lastline > 0 {
|
} else if lastline > 0 {
|
||||||
fmt.Fprintf(out, "\n")
|
fmt.Fprintf(out, "\n")
|
||||||
lastline = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(out, "Checked %d references in total\n", total)
|
fmt.Fprintf(out, "Checked %d references in total\n", total)
|
||||||
|
@ -224,7 +224,6 @@ func DecodeSectionKey(encoded string) (string, string) {
|
|||||||
if !inKey {
|
if !inKey {
|
||||||
if splitter := strings.Index(remaining, "__"); splitter > -1 {
|
if splitter := strings.Index(remaining, "__"); splitter > -1 {
|
||||||
section += remaining[:splitter]
|
section += remaining[:splitter]
|
||||||
inKey = true
|
|
||||||
key += remaining[splitter+2:]
|
key += remaining[splitter+2:]
|
||||||
} else {
|
} else {
|
||||||
section += remaining
|
section += remaining
|
||||||
|
@ -119,9 +119,9 @@ func TestAPIGetComment(t *testing.T) {
|
|||||||
session := loginUser(t, repoOwner.Name)
|
session := loginUser(t, repoOwner.Name)
|
||||||
token := getTokenForLoggedInUser(t, session)
|
token := getTokenForLoggedInUser(t, session)
|
||||||
req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d", repoOwner.Name, repo.Name, comment.ID)
|
req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d", repoOwner.Name, repo.Name, comment.ID)
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token)
|
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token)
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
var apiComment api.Comment
|
var apiComment api.Comment
|
||||||
DecodeJSON(t, resp, &apiComment)
|
DecodeJSON(t, resp, &apiComment)
|
||||||
|
@ -83,7 +83,7 @@ func TestAPIModifyLabels(t *testing.T) {
|
|||||||
|
|
||||||
//DeleteLabel
|
//DeleteLabel
|
||||||
req = NewRequest(t, "DELETE", singleURLStr)
|
req = NewRequest(t, "DELETE", singleURLStr)
|
||||||
resp = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +203,6 @@ func TestAPIModifyOrgLabels(t *testing.T) {
|
|||||||
|
|
||||||
//DeleteLabel
|
//DeleteLabel
|
||||||
req = NewRequest(t, "DELETE", singleURLStr)
|
req = NewRequest(t, "DELETE", singleURLStr)
|
||||||
resp = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,5 +74,5 @@ func TestAPIIssuesMilestone(t *testing.T) {
|
|||||||
assert.Equal(t, int64(2), apiMilestones[0].ID)
|
assert.Equal(t, int64(2), apiMilestones[0].ID)
|
||||||
|
|
||||||
req = NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%d?token=%s", owner.Name, repo.Name, apiMilestone.ID, token))
|
req = NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%d?token=%s", owner.Name, repo.Name, apiMilestone.ID, token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
@ -36,24 +36,24 @@ func TestAPIIssuesReactions(t *testing.T) {
|
|||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
||||||
Reaction: "wrong",
|
Reaction: "wrong",
|
||||||
})
|
})
|
||||||
resp := session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
//Delete not allowed reaction
|
//Delete not allowed reaction
|
||||||
req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{
|
req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{
|
||||||
Reaction: "zzz",
|
Reaction: "zzz",
|
||||||
})
|
})
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
//Add allowed reaction
|
//Add allowed reaction
|
||||||
req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
||||||
Reaction: "rocket",
|
Reaction: "rocket",
|
||||||
})
|
})
|
||||||
resp = session.MakeRequest(t, req, http.StatusCreated)
|
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiNewReaction api.Reaction
|
var apiNewReaction api.Reaction
|
||||||
DecodeJSON(t, resp, &apiNewReaction)
|
DecodeJSON(t, resp, &apiNewReaction)
|
||||||
|
|
||||||
//Add existing reaction
|
//Add existing reaction
|
||||||
resp = session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
//Get end result of reaction list of issue #1
|
//Get end result of reaction list of issue #1
|
||||||
req = NewRequestf(t, "GET", urlStr)
|
req = NewRequestf(t, "GET", urlStr)
|
||||||
@ -96,24 +96,24 @@ func TestAPICommentReactions(t *testing.T) {
|
|||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
||||||
Reaction: "wrong",
|
Reaction: "wrong",
|
||||||
})
|
})
|
||||||
resp := session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
//Delete none existing reaction
|
//Delete none existing reaction
|
||||||
req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{
|
req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{
|
||||||
Reaction: "eyes",
|
Reaction: "eyes",
|
||||||
})
|
})
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
//Add allowed reaction
|
//Add allowed reaction
|
||||||
req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
|
||||||
Reaction: "+1",
|
Reaction: "+1",
|
||||||
})
|
})
|
||||||
resp = session.MakeRequest(t, req, http.StatusCreated)
|
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiNewReaction api.Reaction
|
var apiNewReaction api.Reaction
|
||||||
DecodeJSON(t, resp, &apiNewReaction)
|
DecodeJSON(t, resp, &apiNewReaction)
|
||||||
|
|
||||||
//Add existing reaction
|
//Add existing reaction
|
||||||
resp = session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
//Get end result of reaction list of issue #1
|
//Get end result of reaction list of issue #1
|
||||||
req = NewRequestf(t, "GET", urlStr)
|
req = NewRequestf(t, "GET", urlStr)
|
||||||
|
@ -66,7 +66,7 @@ func TestAPINotification(t *testing.T) {
|
|||||||
// -- GET /notifications/threads/{id} --
|
// -- GET /notifications/threads/{id} --
|
||||||
// get forbidden
|
// get forbidden
|
||||||
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", 1, token))
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", 1, token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
// get own
|
// get own
|
||||||
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
|
||||||
@ -100,7 +100,7 @@ func TestAPINotification(t *testing.T) {
|
|||||||
|
|
||||||
lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" //946687801 <- only Notification 4 is in this filter ...
|
lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" //946687801 <- only Notification 4 is in this filter ...
|
||||||
req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token))
|
req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusResetContent)
|
session.MakeRequest(t, req, http.StatusResetContent)
|
||||||
|
|
||||||
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?status-types=unread&token=%s", token))
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?status-types=unread&token=%s", token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
@ -109,7 +109,7 @@ func TestAPINotification(t *testing.T) {
|
|||||||
|
|
||||||
// -- PATCH /notifications/threads/{id} --
|
// -- PATCH /notifications/threads/{id} --
|
||||||
req = NewRequest(t, "PATCH", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
|
req = NewRequest(t, "PATCH", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusResetContent)
|
session.MakeRequest(t, req, http.StatusResetContent)
|
||||||
|
|
||||||
assert.Equal(t, models.NotificationStatusUnread, thread5.Status)
|
assert.Equal(t, models.NotificationStatusUnread, thread5.Status)
|
||||||
thread5 = unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5}).(*models.Notification)
|
thread5 = unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5}).(*models.Notification)
|
||||||
|
@ -140,7 +140,7 @@ func TestAPIPullReview(t *testing.T) {
|
|||||||
assert.EqualValues(t, "COMMENT", review.State)
|
assert.EqualValues(t, "COMMENT", review.State)
|
||||||
assert.EqualValues(t, 0, review.CodeCommentsCount)
|
assert.EqualValues(t, 0, review.CodeCommentsCount)
|
||||||
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token)
|
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token)
|
||||||
resp = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
// test CreatePullReview Comment without body but with comments
|
// test CreatePullReview Comment without body but with comments
|
||||||
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
|
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
|
||||||
|
@ -145,7 +145,6 @@ func TestAPIRepoEdit(t *testing.T) {
|
|||||||
// Get user2's token
|
// Get user2's token
|
||||||
session := loginUser(t, user2.Name)
|
session := loginUser(t, user2.Name)
|
||||||
token2 := getTokenForLoggedInUser(t, session)
|
token2 := getTokenForLoggedInUser(t, session)
|
||||||
session = emptyTestSession(t)
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
token4 := getTokenForLoggedInUser(t, session)
|
token4 := getTokenForLoggedInUser(t, session)
|
||||||
@ -223,15 +222,15 @@ func TestAPIRepoEdit(t *testing.T) {
|
|||||||
// Do some tests with invalid URL for external tracker and wiki
|
// Do some tests with invalid URL for external tracker and wiki
|
||||||
repoEditOption.ExternalTracker.ExternalTrackerURL = "htp://www.somewebsite.com"
|
repoEditOption.ExternalTracker.ExternalTrackerURL = "htp://www.somewebsite.com"
|
||||||
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
|
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
|
||||||
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
repoEditOption.ExternalTracker.ExternalTrackerURL = "http://www.somewebsite.com"
|
repoEditOption.ExternalTracker.ExternalTrackerURL = "http://www.somewebsite.com"
|
||||||
repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user/{repo}?issue={index}"
|
repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user/{repo}?issue={index}"
|
||||||
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
|
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
|
||||||
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user}/{repo}?issue={index}"
|
repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user}/{repo}?issue={index}"
|
||||||
repoEditOption.ExternalWiki.ExternalWikiURL = "htp://www.somewebsite.com"
|
repoEditOption.ExternalWiki.ExternalWikiURL = "htp://www.somewebsite.com"
|
||||||
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
|
req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
|
||||||
resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
|
|
||||||
//Test small repo change through API with issue and wiki option not set; They shall not be touched.
|
//Test small repo change through API with issue and wiki option not set; They shall not be touched.
|
||||||
*repoEditOption.Description = "small change"
|
*repoEditOption.Description = "small change"
|
||||||
|
@ -149,7 +149,6 @@ func TestAPICreateFile(t *testing.T) {
|
|||||||
// Get user2's token
|
// Get user2's token
|
||||||
session := loginUser(t, user2.Name)
|
session := loginUser(t, user2.Name)
|
||||||
token2 := getTokenForLoggedInUser(t, session)
|
token2 := getTokenForLoggedInUser(t, session)
|
||||||
session = emptyTestSession(t)
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
token4 := getTokenForLoggedInUser(t, session)
|
token4 := getTokenForLoggedInUser(t, session)
|
||||||
|
@ -49,7 +49,6 @@ func TestAPIDeleteFile(t *testing.T) {
|
|||||||
// Get user2's token
|
// Get user2's token
|
||||||
session := loginUser(t, user2.Name)
|
session := loginUser(t, user2.Name)
|
||||||
token2 := getTokenForLoggedInUser(t, session)
|
token2 := getTokenForLoggedInUser(t, session)
|
||||||
session = emptyTestSession(t)
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
token4 := getTokenForLoggedInUser(t, session)
|
token4 := getTokenForLoggedInUser(t, session)
|
||||||
@ -111,7 +110,7 @@ func TestAPIDeleteFile(t *testing.T) {
|
|||||||
deleteFileOptions.SHA = "badsha"
|
deleteFileOptions.SHA = "badsha"
|
||||||
url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
|
url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
|
||||||
req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions)
|
req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions)
|
||||||
resp = session.MakeRequest(t, req, http.StatusBadRequest)
|
session.MakeRequest(t, req, http.StatusBadRequest)
|
||||||
|
|
||||||
// Test creating a file in repo16 by user4 who does not have write access
|
// Test creating a file in repo16 by user4 who does not have write access
|
||||||
fileID++
|
fileID++
|
||||||
|
@ -115,7 +115,6 @@ func TestAPIUpdateFile(t *testing.T) {
|
|||||||
// Get user2's token
|
// Get user2's token
|
||||||
session := loginUser(t, user2.Name)
|
session := loginUser(t, user2.Name)
|
||||||
token2 := getTokenForLoggedInUser(t, session)
|
token2 := getTokenForLoggedInUser(t, session)
|
||||||
session = emptyTestSession(t)
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
token4 := getTokenForLoggedInUser(t, session)
|
token4 := getTokenForLoggedInUser(t, session)
|
||||||
|
@ -64,7 +64,6 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
|||||||
// Get user2's token
|
// Get user2's token
|
||||||
session := loginUser(t, user2.Name)
|
session := loginUser(t, user2.Name)
|
||||||
token2 := getTokenForLoggedInUser(t, session)
|
token2 := getTokenForLoggedInUser(t, session)
|
||||||
session = emptyTestSession(t)
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
token4 := getTokenForLoggedInUser(t, session)
|
token4 := getTokenForLoggedInUser(t, session)
|
||||||
@ -139,7 +138,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
|||||||
// Test file contents a file with a bad ref
|
// Test file contents a file with a bad ref
|
||||||
ref = "badref"
|
ref = "badref"
|
||||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
|
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
|
||||||
resp = session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
// Test accessing private ref with user token that does not have access - should fail
|
// Test accessing private ref with user token that does not have access - should fail
|
||||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)
|
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)
|
||||||
|
@ -65,7 +65,6 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
|||||||
// Get user2's token
|
// Get user2's token
|
||||||
session := loginUser(t, user2.Name)
|
session := loginUser(t, user2.Name)
|
||||||
token2 := getTokenForLoggedInUser(t, session)
|
token2 := getTokenForLoggedInUser(t, session)
|
||||||
session = emptyTestSession(t)
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
token4 := getTokenForLoggedInUser(t, session)
|
token4 := getTokenForLoggedInUser(t, session)
|
||||||
@ -141,7 +140,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
|||||||
// Test file contents a file with a bad ref
|
// Test file contents a file with a bad ref
|
||||||
ref = "badref"
|
ref = "badref"
|
||||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
|
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
|
||||||
resp = session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
// Test accessing private ref with user token that does not have access - should fail
|
// Test accessing private ref with user token that does not have access - should fail
|
||||||
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)
|
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)
|
||||||
|
@ -62,10 +62,10 @@ func TestAPIRepoTags(t *testing.T) {
|
|||||||
|
|
||||||
// delete tag
|
// delete tag
|
||||||
delReq := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/tags/%s?token=%s", user.Name, repoName, newTag.Name, token)
|
delReq := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/tags/%s?token=%s", user.Name, repoName, newTag.Name, token)
|
||||||
resp = session.MakeRequest(t, delReq, http.StatusNoContent)
|
session.MakeRequest(t, delReq, http.StatusNoContent)
|
||||||
|
|
||||||
// check if it's gone
|
// check if it's gone
|
||||||
resp = session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNewTagUsingAPI(t *testing.T, session *TestSession, token string, ownerName, repoName, name, target, msg string) *api.Tag {
|
func createNewTagUsingAPI(t *testing.T, session *TestSession, token string, ownerName, repoName, name, target, msg string) *api.Tag {
|
||||||
|
@ -54,12 +54,12 @@ func TestAPIRepoTeams(t *testing.T) {
|
|||||||
|
|
||||||
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "NonExistingTeam", token)
|
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "NonExistingTeam", token)
|
||||||
req = NewRequest(t, "GET", url)
|
req = NewRequest(t, "GET", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
// AddTeam with user4
|
// AddTeam with user4
|
||||||
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
|
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
|
||||||
req = NewRequest(t, "PUT", url)
|
req = NewRequest(t, "PUT", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
// AddTeam with user2
|
// AddTeam with user2
|
||||||
user = unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
user = unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
|
||||||
@ -67,12 +67,12 @@ func TestAPIRepoTeams(t *testing.T) {
|
|||||||
token = getTokenForLoggedInUser(t, session)
|
token = getTokenForLoggedInUser(t, session)
|
||||||
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
|
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
|
||||||
req = NewRequest(t, "PUT", url)
|
req = NewRequest(t, "PUT", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
res = session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
|
||||||
|
|
||||||
// DeleteTeam
|
// DeleteTeam
|
||||||
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
|
url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
|
||||||
req = NewRequest(t, "DELETE", url)
|
req = NewRequest(t, "DELETE", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
res = session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
|
||||||
}
|
}
|
||||||
|
@ -75,15 +75,15 @@ func TestAPIRepoTopic(t *testing.T) {
|
|||||||
|
|
||||||
// Test delete a topic
|
// Test delete a topic
|
||||||
req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Topicname1", token2)
|
req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Topicname1", token2)
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
// Test add an existing topic
|
// Test add an existing topic
|
||||||
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Golang", token2)
|
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Golang", token2)
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
// Test add a topic
|
// Test add a topic
|
||||||
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "topicName3", token2)
|
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "topicName3", token2)
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
// Test read topics using token
|
// Test read topics using token
|
||||||
req = NewRequest(t, "GET", url)
|
req = NewRequest(t, "GET", url)
|
||||||
@ -96,7 +96,7 @@ func TestAPIRepoTopic(t *testing.T) {
|
|||||||
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
||||||
Topics: newTopics,
|
Topics: newTopics,
|
||||||
})
|
})
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
req = NewRequest(t, "GET", url)
|
req = NewRequest(t, "GET", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusOK)
|
res = session.MakeRequest(t, req, http.StatusOK)
|
||||||
DecodeJSON(t, res, &topics)
|
DecodeJSON(t, res, &topics)
|
||||||
@ -107,7 +107,7 @@ func TestAPIRepoTopic(t *testing.T) {
|
|||||||
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
||||||
Topics: newTopics,
|
Topics: newTopics,
|
||||||
})
|
})
|
||||||
res = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
req = NewRequest(t, "GET", url)
|
req = NewRequest(t, "GET", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusOK)
|
res = session.MakeRequest(t, req, http.StatusOK)
|
||||||
DecodeJSON(t, res, &topics)
|
DecodeJSON(t, res, &topics)
|
||||||
@ -118,7 +118,7 @@ func TestAPIRepoTopic(t *testing.T) {
|
|||||||
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
||||||
Topics: newTopics,
|
Topics: newTopics,
|
||||||
})
|
})
|
||||||
res = session.MakeRequest(t, req, http.StatusNoContent)
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
req = NewRequest(t, "GET", url)
|
req = NewRequest(t, "GET", url)
|
||||||
res = session.MakeRequest(t, req, http.StatusOK)
|
res = session.MakeRequest(t, req, http.StatusOK)
|
||||||
DecodeJSON(t, res, &topics)
|
DecodeJSON(t, res, &topics)
|
||||||
@ -129,15 +129,15 @@ func TestAPIRepoTopic(t *testing.T) {
|
|||||||
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
|
||||||
Topics: newTopics,
|
Topics: newTopics,
|
||||||
})
|
})
|
||||||
res = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
|
|
||||||
// Test add a topic when there is already maximum
|
// Test add a topic when there is already maximum
|
||||||
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "t26", token2)
|
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "t26", token2)
|
||||||
res = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||||
|
|
||||||
// Test delete a topic that repo doesn't have
|
// Test delete a topic that repo doesn't have
|
||||||
req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Topicname1", token2)
|
req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Topicname1", token2)
|
||||||
res = session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
// Get user4's token
|
// Get user4's token
|
||||||
session = loginUser(t, user4.Name)
|
session = loginUser(t, user4.Name)
|
||||||
@ -153,6 +153,6 @@ func TestAPIRepoTopic(t *testing.T) {
|
|||||||
|
|
||||||
// Test add a topic to repo with write access (requires repo admin access)
|
// Test add a topic to repo with write access (requires repo admin access)
|
||||||
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user3.Name, repo3.Name, "topicName", token4)
|
req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user3.Name, repo3.Name, "topicName", token4)
|
||||||
res = session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,6 @@ func TestAPITeamSearch(t *testing.T) {
|
|||||||
csrf = GetCSRF(t, session, "/"+org.Name)
|
csrf = GetCSRF(t, session, "/"+org.Name)
|
||||||
req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "team")
|
req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "team")
|
||||||
req.Header.Add("X-Csrf-Token", csrf)
|
req.Header.Add("X-Csrf-Token", csrf)
|
||||||
resp = session.MakeRequest(t, req, http.StatusForbidden)
|
session.MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,13 +72,13 @@ func TestMyOrgs(t *testing.T) {
|
|||||||
|
|
||||||
session := emptyTestSession(t)
|
session := emptyTestSession(t)
|
||||||
req := NewRequest(t, "GET", "/api/v1/user/orgs")
|
req := NewRequest(t, "GET", "/api/v1/user/orgs")
|
||||||
resp := session.MakeRequest(t, req, http.StatusUnauthorized)
|
session.MakeRequest(t, req, http.StatusUnauthorized)
|
||||||
|
|
||||||
normalUsername := "user2"
|
normalUsername := "user2"
|
||||||
session = loginUser(t, normalUsername)
|
session = loginUser(t, normalUsername)
|
||||||
token := getTokenForLoggedInUser(t, session)
|
token := getTokenForLoggedInUser(t, session)
|
||||||
req = NewRequest(t, "GET", "/api/v1/user/orgs?token="+token)
|
req = NewRequest(t, "GET", "/api/v1/user/orgs?token="+token)
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
var orgs []*api.Organization
|
var orgs []*api.Organization
|
||||||
DecodeJSON(t, resp, &orgs)
|
DecodeJSON(t, resp, &orgs)
|
||||||
user3 := unittest.AssertExistsAndLoadBean(t, &models.User{Name: "user3"}).(*models.User)
|
user3 := unittest.AssertExistsAndLoadBean(t, &models.User{Name: "user3"}).(*models.User)
|
||||||
|
@ -69,7 +69,7 @@ func TestEventSourceManagerRun(t *testing.T) {
|
|||||||
|
|
||||||
lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" //946687801 <- only Notification 4 is in this filter ...
|
lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" //946687801 <- only Notification 4 is in this filter ...
|
||||||
req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token))
|
req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusResetContent)
|
session.MakeRequest(t, req, http.StatusResetContent)
|
||||||
|
|
||||||
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?token=%s&status-types=unread", token))
|
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?token=%s&status-types=unread", token))
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
@ -287,7 +287,7 @@ func TestIssueCrossReference(t *testing.T) {
|
|||||||
unittest.AssertExistsAndLoadBean(t, comment)
|
unittest.AssertExistsAndLoadBean(t, comment)
|
||||||
|
|
||||||
// Ref from a different repository
|
// Ref from a different repository
|
||||||
issueRefURL, issueRef = testIssueWithBean(t, "user12", 10, "TitleXRef", fmt.Sprintf("Description ref user2/repo1#%d", issueBase.Index))
|
_, issueRef = testIssueWithBean(t, "user12", 10, "TitleXRef", fmt.Sprintf("Description ref user2/repo1#%d", issueBase.Index))
|
||||||
unittest.AssertExistsAndLoadBean(t, &models.Comment{
|
unittest.AssertExistsAndLoadBean(t, &models.Comment{
|
||||||
IssueID: issueBase.ID,
|
IssueID: issueBase.ID,
|
||||||
RefRepoID: 10,
|
RefRepoID: 10,
|
||||||
|
@ -33,12 +33,12 @@ func TestPullCreate_CommitStatus(t *testing.T) {
|
|||||||
|
|
||||||
req = NewRequest(t, "GET", "/user1/repo1/pulls")
|
req = NewRequest(t, "GET", "/user1/repo1/pulls")
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
doc := NewHTMLParser(t, resp.Body)
|
NewHTMLParser(t, resp.Body)
|
||||||
|
|
||||||
// Request repository commits page
|
// Request repository commits page
|
||||||
req = NewRequest(t, "GET", "/user1/repo1/pulls/1/commits")
|
req = NewRequest(t, "GET", "/user1/repo1/pulls/1/commits")
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
doc = NewHTMLParser(t, resp.Body)
|
doc := NewHTMLParser(t, resp.Body)
|
||||||
|
|
||||||
// Get first commit URL
|
// Get first commit URL
|
||||||
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href")
|
commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href")
|
||||||
|
@ -21,11 +21,11 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
|
|||||||
|
|
||||||
// Step0: check the existence of the to-fork repo
|
// Step0: check the existence of the to-fork repo
|
||||||
req := NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)
|
req := NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)
|
||||||
resp := session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
// Step1: go to the main page of repo
|
// Step1: go to the main page of repo
|
||||||
req = NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
|
req = NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
// Step2: click the fork button
|
// Step2: click the fork button
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
@ -21,11 +21,11 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateOwnerName, tem
|
|||||||
|
|
||||||
// Step0: check the existence of the generated repo
|
// Step0: check the existence of the generated repo
|
||||||
req := NewRequestf(t, "GET", "/%s/%s", generateOwnerName, generateRepoName)
|
req := NewRequestf(t, "GET", "/%s/%s", generateOwnerName, generateRepoName)
|
||||||
resp := session.MakeRequest(t, req, http.StatusNotFound)
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
// Step1: go to the main page of template repo
|
// Step1: go to the main page of template repo
|
||||||
req = NewRequestf(t, "GET", "/%s/%s", templateOwnerName, templateRepoName)
|
req = NewRequestf(t, "GET", "/%s/%s", templateOwnerName, templateRepoName)
|
||||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
// Step2: click the "Use this template" button
|
// Step2: click the "Use this template" button
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
@ -72,7 +72,7 @@ func TestMakeIDsFromAPIAssigneesToAdd(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, []int64{}, IDs)
|
assert.Equal(t, []int64{}, IDs)
|
||||||
|
|
||||||
IDs, err = MakeIDsFromAPIAssigneesToAdd("", []string{"none_existing_user"})
|
_, err = MakeIDsFromAPIAssigneesToAdd("", []string{"none_existing_user"})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
||||||
IDs, err = MakeIDsFromAPIAssigneesToAdd("user1", []string{"user1"})
|
IDs, err = MakeIDsFromAPIAssigneesToAdd("user1", []string{"user1"})
|
||||||
|
@ -16,7 +16,6 @@ import (
|
|||||||
func TestAddTopic(t *testing.T) {
|
func TestAddTopic(t *testing.T) {
|
||||||
totalNrOfTopics := 6
|
totalNrOfTopics := 6
|
||||||
repo1NrOfTopics := 3
|
repo1NrOfTopics := 3
|
||||||
repo2NrOfTopics := 2
|
|
||||||
|
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ func TestAddTopic(t *testing.T) {
|
|||||||
assert.Len(t, topics, repo1NrOfTopics)
|
assert.Len(t, topics, repo1NrOfTopics)
|
||||||
|
|
||||||
assert.NoError(t, SaveTopics(2, "golang"))
|
assert.NoError(t, SaveTopics(2, "golang"))
|
||||||
repo2NrOfTopics = 1
|
repo2NrOfTopics := 1
|
||||||
topics, _, err = FindTopics(&FindTopicOptions{})
|
topics, _, err = FindTopics(&FindTopicOptions{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, topics, totalNrOfTopics)
|
assert.Len(t, topics, totalNrOfTopics)
|
||||||
|
@ -111,14 +111,14 @@ func TestListEmails(t *testing.T) {
|
|||||||
|
|
||||||
// Must find only primary addresses (i.e. from the `user` table)
|
// Must find only primary addresses (i.e. from the `user` table)
|
||||||
opts = &SearchEmailOptions{IsPrimary: util.OptionalBoolTrue}
|
opts = &SearchEmailOptions{IsPrimary: util.OptionalBoolTrue}
|
||||||
emails, count, err = SearchEmails(opts)
|
emails, _, err = SearchEmails(opts)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, contains(func(s *SearchEmailResult) bool { return s.IsPrimary }))
|
assert.True(t, contains(func(s *SearchEmailResult) bool { return s.IsPrimary }))
|
||||||
assert.False(t, contains(func(s *SearchEmailResult) bool { return !s.IsPrimary }))
|
assert.False(t, contains(func(s *SearchEmailResult) bool { return !s.IsPrimary }))
|
||||||
|
|
||||||
// Must find only inactive addresses (i.e. not validated)
|
// Must find only inactive addresses (i.e. not validated)
|
||||||
opts = &SearchEmailOptions{IsActivated: util.OptionalBoolFalse}
|
opts = &SearchEmailOptions{IsActivated: util.OptionalBoolFalse}
|
||||||
emails, count, err = SearchEmails(opts)
|
emails, _, err = SearchEmails(opts)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, contains(func(s *SearchEmailResult) bool { return !s.IsActivated }))
|
assert.True(t, contains(func(s *SearchEmailResult) bool { return !s.IsActivated }))
|
||||||
assert.False(t, contains(func(s *SearchEmailResult) bool { return s.IsActivated }))
|
assert.False(t, contains(func(s *SearchEmailResult) bool { return s.IsActivated }))
|
||||||
|
@ -55,11 +55,10 @@ func BenchmarkParseGlyphs(b *testing.B) {
|
|||||||
parser.Reset()
|
parser.Reset()
|
||||||
tgBytes := []byte(testglyphs)
|
tgBytes := []byte(testglyphs)
|
||||||
tg := tgBytes
|
tg := tgBytes
|
||||||
idx := bytes.Index(tg, []byte("\n"))
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
parser.Reset()
|
parser.Reset()
|
||||||
tg = tgBytes
|
tg = tgBytes
|
||||||
idx = bytes.Index(tg, []byte("\n"))
|
idx := bytes.Index(tg, []byte("\n"))
|
||||||
for idx > 0 {
|
for idx > 0 {
|
||||||
parser.ParseGlyphs(tg[:idx])
|
parser.ParseGlyphs(tg[:idx])
|
||||||
tg = tg[idx+1:]
|
tg = tg[idx+1:]
|
||||||
|
@ -48,13 +48,12 @@ func (m *Manager) GetLevelDB(connection string) (*leveldb.DB, error) {
|
|||||||
|
|
||||||
return db.db, nil
|
return db.db, nil
|
||||||
}
|
}
|
||||||
dataDir := connection
|
|
||||||
uri := ToLevelDBURI(connection)
|
uri := ToLevelDBURI(connection)
|
||||||
db = &levelDBHolder{
|
db = &levelDBHolder{
|
||||||
name: []string{connection, uri.String()},
|
name: []string{connection, uri.String()},
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDir = path.Join(uri.Host, uri.Path)
|
dataDir := path.Join(uri.Host, uri.Path)
|
||||||
opts := &opt.Options{}
|
opts := &opt.Options{}
|
||||||
for k, v := range uri.Query() {
|
for k, v := range uri.Query() {
|
||||||
switch replacer.Replace(strings.ToLower(k)) {
|
switch replacer.Replace(strings.ToLower(k)) {
|
||||||
|
@ -93,11 +93,9 @@ func Validate(errs binding.Errors, data map[string]interface{}, f Form, l transl
|
|||||||
AssignForm(f, data)
|
AssignForm(f, data)
|
||||||
|
|
||||||
typ := reflect.TypeOf(f)
|
typ := reflect.TypeOf(f)
|
||||||
val := reflect.ValueOf(f)
|
|
||||||
|
|
||||||
if typ.Kind() == reflect.Ptr {
|
if typ.Kind() == reflect.Ptr {
|
||||||
typ = typ.Elem()
|
typ = typ.Elem()
|
||||||
val = val.Elem()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if field, ok := typ.FieldByName(errs[0].FieldNames[0]); ok {
|
if field, ok := typ.FieldByName(errs[0].FieldNames[0]); ok {
|
||||||
|
@ -91,7 +91,6 @@ func TeamsAction(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = ctx.Org.Team.RemoveMember(uid)
|
err = ctx.Org.Team.RemoveMember(uid)
|
||||||
page = "team"
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrLastOrgOwner(err) {
|
if models.IsErrLastOrgOwner(err) {
|
||||||
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
|
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
|
||||||
|
Loading…
Reference in New Issue
Block a user