[FEAT] allow setting the update date on issues and comments (squash) do not use token= query param
See https://codeberg.org/forgejo/forgejo/commit/33439b733a
This commit is contained in:
parent
868b7a436f
commit
c5139a75b9
|
@ -132,8 +132,8 @@ func TestAPICreateCommentAttachmentAutoDate(t *testing.T) {
|
||||||
|
|
||||||
session := loginUser(t, repoOwner.Name)
|
session := loginUser(t, repoOwner.Name)
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d/assets?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d/assets",
|
||||||
repoOwner.Name, repo.Name, comment.ID, token)
|
repoOwner.Name, repo.Name, comment.ID)
|
||||||
|
|
||||||
filename := "image.png"
|
filename := "image.png"
|
||||||
buff := generateImg()
|
buff := generateImg()
|
||||||
|
@ -151,7 +151,7 @@ func TestAPICreateCommentAttachmentAutoDate(t *testing.T) {
|
||||||
err = writer.Close()
|
err = writer.Close()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
req := NewRequestWithBody(t, "POST", urlStr, body)
|
req := NewRequestWithBody(t, "POST", urlStr, body).AddTokenAuth(token)
|
||||||
req.Header.Add("Content-Type", writer.FormDataContentType())
|
req.Header.Add("Content-Type", writer.FormDataContentType())
|
||||||
resp := session.MakeRequest(t, req, http.StatusCreated)
|
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||||
apiAttachment := new(api.Attachment)
|
apiAttachment := new(api.Attachment)
|
||||||
|
@ -171,7 +171,7 @@ func TestAPICreateCommentAttachmentAutoDate(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
||||||
urlStr += fmt.Sprintf("&updated_at=%s", updatedAt.UTC().Format(time.RFC3339))
|
urlStr += fmt.Sprintf("?updated_at=%s", updatedAt.UTC().Format(time.RFC3339))
|
||||||
|
|
||||||
// Setup multi-part
|
// Setup multi-part
|
||||||
writer := multipart.NewWriter(body)
|
writer := multipart.NewWriter(body)
|
||||||
|
@ -182,7 +182,7 @@ func TestAPICreateCommentAttachmentAutoDate(t *testing.T) {
|
||||||
err = writer.Close()
|
err = writer.Close()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
req := NewRequestWithBody(t, "POST", urlStr, body)
|
req := NewRequestWithBody(t, "POST", urlStr, body).AddTokenAuth(token)
|
||||||
req.Header.Add("Content-Type", writer.FormDataContentType())
|
req.Header.Add("Content-Type", writer.FormDataContentType())
|
||||||
resp := session.MakeRequest(t, req, http.StatusCreated)
|
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||||
apiAttachment := new(api.Attachment)
|
apiAttachment := new(api.Attachment)
|
||||||
|
|
|
@ -120,8 +120,8 @@ func TestAPICreateCommentAutoDate(t *testing.T) {
|
||||||
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
||||||
token := getUserToken(t, repoOwner.Name, auth_model.AccessTokenScopeWriteIssue)
|
token := getUserToken(t, repoOwner.Name, auth_model.AccessTokenScopeWriteIssue)
|
||||||
|
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments",
|
||||||
repoOwner.Name, repo.Name, issue.Index, token)
|
repoOwner.Name, repo.Name, issue.Index)
|
||||||
const commentBody = "Comment body"
|
const commentBody = "Comment body"
|
||||||
|
|
||||||
t.Run("WithAutoDate", func(t *testing.T) {
|
t.Run("WithAutoDate", func(t *testing.T) {
|
||||||
|
@ -129,7 +129,7 @@ func TestAPICreateCommentAutoDate(t *testing.T) {
|
||||||
|
|
||||||
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
|
req := NewRequestWithValues(t, "POST", urlStr, map[string]string{
|
||||||
"body": commentBody,
|
"body": commentBody,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var updatedComment api.Comment
|
var updatedComment api.Comment
|
||||||
DecodeJSON(t, resp, &updatedComment)
|
DecodeJSON(t, resp, &updatedComment)
|
||||||
|
@ -151,7 +151,7 @@ func TestAPICreateCommentAutoDate(t *testing.T) {
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueCommentOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueCommentOption{
|
||||||
Body: commentBody,
|
Body: commentBody,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var updatedComment api.Comment
|
var updatedComment api.Comment
|
||||||
DecodeJSON(t, resp, &updatedComment)
|
DecodeJSON(t, resp, &updatedComment)
|
||||||
|
@ -177,13 +177,13 @@ func TestAPICommentXRefAutoDate(t *testing.T) {
|
||||||
|
|
||||||
// Create a comment mentioning issue #2 and check that a xref comment was added
|
// Create a comment mentioning issue #2 and check that a xref comment was added
|
||||||
// in issue #2
|
// in issue #2
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments",
|
||||||
repoOwner.Name, repo.Name, issue.Index, token)
|
repoOwner.Name, repo.Name, issue.Index)
|
||||||
|
|
||||||
commentBody := "mention #2"
|
commentBody := "mention #2"
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueCommentOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueCommentOption{
|
||||||
Body: commentBody,
|
Body: commentBody,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var createdComment api.Comment
|
var createdComment api.Comment
|
||||||
DecodeJSON(t, resp, &createdComment)
|
DecodeJSON(t, resp, &createdComment)
|
||||||
|
@ -196,13 +196,13 @@ func TestAPICommentXRefAutoDate(t *testing.T) {
|
||||||
assert.LessOrEqual(t, updatedSince, time.Minute)
|
assert.LessOrEqual(t, updatedSince, time.Minute)
|
||||||
|
|
||||||
// Remove the mention to issue #2 and check that the xref was neutered
|
// Remove the mention to issue #2 and check that the xref was neutered
|
||||||
urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d?token=%s",
|
urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d",
|
||||||
repoOwner.Name, repo.Name, createdComment.ID, token)
|
repoOwner.Name, repo.Name, createdComment.ID)
|
||||||
|
|
||||||
newCommentBody := "no mention"
|
newCommentBody := "no mention"
|
||||||
req = NewRequestWithJSON(t, "PATCH", urlStr, &api.EditIssueCommentOption{
|
req = NewRequestWithJSON(t, "PATCH", urlStr, &api.EditIssueCommentOption{
|
||||||
Body: newCommentBody,
|
Body: newCommentBody,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp = MakeRequest(t, req, http.StatusOK)
|
resp = MakeRequest(t, req, http.StatusOK)
|
||||||
var updatedComment api.Comment
|
var updatedComment api.Comment
|
||||||
DecodeJSON(t, resp, &updatedComment)
|
DecodeJSON(t, resp, &updatedComment)
|
||||||
|
@ -223,15 +223,15 @@ func TestAPICommentXRefAutoDate(t *testing.T) {
|
||||||
|
|
||||||
// Create a comment mentioning issue #2 and check that a xref comment was added
|
// Create a comment mentioning issue #2 and check that a xref comment was added
|
||||||
// in issue #2
|
// in issue #2
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments",
|
||||||
repoOwner.Name, repo.Name, issue.Index, token)
|
repoOwner.Name, repo.Name, issue.Index)
|
||||||
|
|
||||||
commentBody := "re-mention #2"
|
commentBody := "re-mention #2"
|
||||||
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueCommentOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.CreateIssueCommentOption{
|
||||||
Body: commentBody,
|
Body: commentBody,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var createdComment api.Comment
|
var createdComment api.Comment
|
||||||
DecodeJSON(t, resp, &createdComment)
|
DecodeJSON(t, resp, &createdComment)
|
||||||
|
@ -242,15 +242,15 @@ func TestAPICommentXRefAutoDate(t *testing.T) {
|
||||||
assert.Equal(t, updatedAt.In(utcTZ), ref.UpdatedUnix.AsTimeInLocation(utcTZ))
|
assert.Equal(t, updatedAt.In(utcTZ), ref.UpdatedUnix.AsTimeInLocation(utcTZ))
|
||||||
|
|
||||||
// Remove the mention to issue #2 and check that the xref was neutered
|
// Remove the mention to issue #2 and check that the xref was neutered
|
||||||
urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d?token=%s",
|
urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d",
|
||||||
repoOwner.Name, repo.Name, createdComment.ID, token)
|
repoOwner.Name, repo.Name, createdComment.ID)
|
||||||
|
|
||||||
newCommentBody := "no mention"
|
newCommentBody := "no mention"
|
||||||
updatedAt = time.Now().Add(-time.Hour).Truncate(time.Second)
|
updatedAt = time.Now().Add(-time.Hour).Truncate(time.Second)
|
||||||
req = NewRequestWithJSON(t, "PATCH", urlStr, &api.EditIssueCommentOption{
|
req = NewRequestWithJSON(t, "PATCH", urlStr, &api.EditIssueCommentOption{
|
||||||
Body: newCommentBody,
|
Body: newCommentBody,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp = MakeRequest(t, req, http.StatusOK)
|
resp = MakeRequest(t, req, http.StatusOK)
|
||||||
var updatedComment api.Comment
|
var updatedComment api.Comment
|
||||||
DecodeJSON(t, resp, &updatedComment)
|
DecodeJSON(t, resp, &updatedComment)
|
||||||
|
@ -374,8 +374,8 @@ func TestAPIEditCommentWithDate(t *testing.T) {
|
||||||
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
||||||
token := getUserToken(t, repoOwner.Name, auth_model.AccessTokenScopeWriteIssue)
|
token := getUserToken(t, repoOwner.Name, auth_model.AccessTokenScopeWriteIssue)
|
||||||
|
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/comments/%d",
|
||||||
repoOwner.Name, repo.Name, comment.ID, token)
|
repoOwner.Name, repo.Name, comment.ID)
|
||||||
const newCommentBody = "This is the new comment body"
|
const newCommentBody = "This is the new comment body"
|
||||||
|
|
||||||
t.Run("WithAutoDate", func(t *testing.T) {
|
t.Run("WithAutoDate", func(t *testing.T) {
|
||||||
|
@ -383,7 +383,7 @@ func TestAPIEditCommentWithDate(t *testing.T) {
|
||||||
|
|
||||||
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
|
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
|
||||||
"body": newCommentBody,
|
"body": newCommentBody,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
var updatedComment api.Comment
|
var updatedComment api.Comment
|
||||||
DecodeJSON(t, resp, &updatedComment)
|
DecodeJSON(t, resp, &updatedComment)
|
||||||
|
@ -405,7 +405,7 @@ func TestAPIEditCommentWithDate(t *testing.T) {
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, &api.EditIssueCommentOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, &api.EditIssueCommentOption{
|
||||||
Body: newCommentBody,
|
Body: newCommentBody,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
var updatedComment api.Comment
|
var updatedComment api.Comment
|
||||||
DecodeJSON(t, resp, &updatedComment)
|
DecodeJSON(t, resp, &updatedComment)
|
||||||
|
|
|
@ -107,8 +107,8 @@ func TestAPICreateIssueAttachmentAutoDate(t *testing.T) {
|
||||||
|
|
||||||
session := loginUser(t, repoOwner.Name)
|
session := loginUser(t, repoOwner.Name)
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/assets?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/assets",
|
||||||
repoOwner.Name, repo.Name, issue.Index, token)
|
repoOwner.Name, repo.Name, issue.Index)
|
||||||
|
|
||||||
filename := "image.png"
|
filename := "image.png"
|
||||||
buff := generateImg()
|
buff := generateImg()
|
||||||
|
@ -126,7 +126,7 @@ func TestAPICreateIssueAttachmentAutoDate(t *testing.T) {
|
||||||
err = writer.Close()
|
err = writer.Close()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
req := NewRequestWithBody(t, "POST", urlStr, body)
|
req := NewRequestWithBody(t, "POST", urlStr, body).AddTokenAuth(token)
|
||||||
req.Header.Add("Content-Type", writer.FormDataContentType())
|
req.Header.Add("Content-Type", writer.FormDataContentType())
|
||||||
resp := session.MakeRequest(t, req, http.StatusCreated)
|
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ func TestAPICreateIssueAttachmentAutoDate(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
||||||
urlStr += fmt.Sprintf("&updated_at=%s", updatedAt.UTC().Format(time.RFC3339))
|
urlStr += fmt.Sprintf("?updated_at=%s", updatedAt.UTC().Format(time.RFC3339))
|
||||||
|
|
||||||
// Setup multi-part
|
// Setup multi-part
|
||||||
writer := multipart.NewWriter(body)
|
writer := multipart.NewWriter(body)
|
||||||
|
@ -158,7 +158,7 @@ func TestAPICreateIssueAttachmentAutoDate(t *testing.T) {
|
||||||
err = writer.Close()
|
err = writer.Close()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
req := NewRequestWithBody(t, "POST", urlStr, body)
|
req := NewRequestWithBody(t, "POST", urlStr, body).AddTokenAuth(token)
|
||||||
req.Header.Add("Content-Type", writer.FormDataContentType())
|
req.Header.Add("Content-Type", writer.FormDataContentType())
|
||||||
resp := session.MakeRequest(t, req, http.StatusCreated)
|
resp := session.MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
|
|
|
@ -125,15 +125,15 @@ func TestAPIAddIssueLabelsAutoDate(t *testing.T) {
|
||||||
|
|
||||||
session := loginUser(t, owner.Name)
|
session := loginUser(t, owner.Name)
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/labels?token=%s",
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/labels",
|
||||||
owner.Name, repo.Name, issueBefore.Index, token)
|
owner.Name, repo.Name, issueBefore.Index)
|
||||||
|
|
||||||
t.Run("WithAutoDate", func(t *testing.T) {
|
t.Run("WithAutoDate", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.IssueLabelsOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.IssueLabelsOption{
|
||||||
Labels: []int64{1},
|
Labels: []int64{1},
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
issueAfter := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issueBefore.ID})
|
issueAfter := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issueBefore.ID})
|
||||||
|
@ -149,7 +149,7 @@ func TestAPIAddIssueLabelsAutoDate(t *testing.T) {
|
||||||
req := NewRequestWithJSON(t, "POST", urlStr, &api.IssueLabelsOption{
|
req := NewRequestWithJSON(t, "POST", urlStr, &api.IssueLabelsOption{
|
||||||
Labels: []int64{2},
|
Labels: []int64{2},
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusOK)
|
MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
// dates will be converted into the same tz, in order to compare them
|
// dates will be converted into the same tz, in order to compare them
|
||||||
|
|
|
@ -227,12 +227,12 @@ func TestAPIEditIssueAutoDate(t *testing.T) {
|
||||||
// User2 is not owner, but can update the 'public' issue with auto date
|
// User2 is not owner, but can update the 'public' issue with auto date
|
||||||
session := loginUser(t, "user2")
|
session := loginUser(t, "user2")
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d?token=%s", owner.Name, repoBefore.Name, issueBefore.Index, token)
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d", owner.Name, repoBefore.Name, issueBefore.Index)
|
||||||
|
|
||||||
body := "new content!"
|
body := "new content!"
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
||||||
Body: &body,
|
Body: &body,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiIssue api.Issue
|
var apiIssue api.Issue
|
||||||
DecodeJSON(t, resp, &apiIssue)
|
DecodeJSON(t, resp, &apiIssue)
|
||||||
|
@ -252,14 +252,14 @@ func TestAPIEditIssueAutoDate(t *testing.T) {
|
||||||
// User1 is admin, and so can update the issue without auto date
|
// User1 is admin, and so can update the issue without auto date
|
||||||
session := loginUser(t, "user1")
|
session := loginUser(t, "user1")
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d?token=%s", owner.Name, repoBefore.Name, issueBefore.Index, token)
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d", owner.Name, repoBefore.Name, issueBefore.Index)
|
||||||
|
|
||||||
body := "new content, with updated time"
|
body := "new content, with updated time"
|
||||||
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
||||||
Body: &body,
|
Body: &body,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusCreated)
|
resp := MakeRequest(t, req, http.StatusCreated)
|
||||||
var apiIssue api.Issue
|
var apiIssue api.Issue
|
||||||
DecodeJSON(t, resp, &apiIssue)
|
DecodeJSON(t, resp, &apiIssue)
|
||||||
|
@ -278,14 +278,14 @@ func TestAPIEditIssueAutoDate(t *testing.T) {
|
||||||
// User2 is not owner nor admin, and so can't update the issue without auto date
|
// User2 is not owner nor admin, and so can't update the issue without auto date
|
||||||
session := loginUser(t, "user2")
|
session := loginUser(t, "user2")
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d?token=%s", owner.Name, repoBefore.Name, issueBefore.Index, token)
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d", owner.Name, repoBefore.Name, issueBefore.Index)
|
||||||
|
|
||||||
body := "new content, with updated time"
|
body := "new content, with updated time"
|
||||||
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
updatedAt := time.Now().Add(-time.Hour).Truncate(time.Second)
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
||||||
Body: &body,
|
Body: &body,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
resp := MakeRequest(t, req, http.StatusForbidden)
|
resp := MakeRequest(t, req, http.StatusForbidden)
|
||||||
var apiError api.APIError
|
var apiError api.APIError
|
||||||
DecodeJSON(t, resp, &apiError)
|
DecodeJSON(t, resp, &apiError)
|
||||||
|
@ -305,7 +305,7 @@ func TestAPIEditIssueMilestoneAutoDate(t *testing.T) {
|
||||||
|
|
||||||
session := loginUser(t, owner.Name)
|
session := loginUser(t, owner.Name)
|
||||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
|
||||||
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d?token=%s", owner.Name, repoBefore.Name, issueBefore.Index, token)
|
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d", owner.Name, repoBefore.Name, issueBefore.Index)
|
||||||
|
|
||||||
t.Run("WithAutoDate", func(t *testing.T) {
|
t.Run("WithAutoDate", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
@ -313,7 +313,7 @@ func TestAPIEditIssueMilestoneAutoDate(t *testing.T) {
|
||||||
milestone := int64(1)
|
milestone := int64(1)
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
||||||
Milestone: &milestone,
|
Milestone: &milestone,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusCreated)
|
MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
// the execution of the API call supposedly lasted less than one minute
|
// the execution of the API call supposedly lasted less than one minute
|
||||||
|
@ -332,7 +332,7 @@ func TestAPIEditIssueMilestoneAutoDate(t *testing.T) {
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
||||||
Milestone: &milestone,
|
Milestone: &milestone,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusCreated)
|
MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
// the milestone date should be set to 'updatedAt'
|
// the milestone date should be set to 'updatedAt'
|
||||||
|
@ -353,7 +353,7 @@ func TestAPIEditIssueMilestoneAutoDate(t *testing.T) {
|
||||||
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
req := NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{
|
||||||
Milestone: &milestone,
|
Milestone: &milestone,
|
||||||
Updated: &updatedAt,
|
Updated: &updatedAt,
|
||||||
})
|
}).AddTokenAuth(token)
|
||||||
MakeRequest(t, req, http.StatusCreated)
|
MakeRequest(t, req, http.StatusCreated)
|
||||||
|
|
||||||
// the milestone date should not change
|
// the milestone date should not change
|
||||||
|
|
Loading…
Reference in New Issue