[TESTS] pull review deleted from gitea#29888
Instead of db.TruncateBeans(db.DefaultContext, &issues_model.Review{}), reviews are deleted using issue.DeleteReview
This commit is contained in:
parent
b2312f32c4
commit
6b857193ff
|
@ -75,3 +75,11 @@
|
||||||
content: "comment in private pository"
|
content: "comment in private pository"
|
||||||
created_unix: 946684811
|
created_unix: 946684811
|
||||||
updated_unix: 946684811
|
updated_unix: 946684811
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 9
|
||||||
|
type: 22 # review
|
||||||
|
poster_id: 2
|
||||||
|
issue_id: 2 # in repo_id 1
|
||||||
|
review_id: 20
|
||||||
|
created_unix: 946684810
|
||||||
|
|
|
@ -170,3 +170,12 @@
|
||||||
content: "review request for user15"
|
content: "review request for user15"
|
||||||
updated_unix: 946684835
|
updated_unix: 946684835
|
||||||
created_unix: 946684835
|
created_unix: 946684835
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 20
|
||||||
|
type: 22
|
||||||
|
reviewer_id: 1
|
||||||
|
issue_id: 2
|
||||||
|
content: "Review Comment"
|
||||||
|
updated_unix: 946684810
|
||||||
|
created_unix: 946684810
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -75,4 +76,30 @@ func TestRenderConversation(t *testing.T) {
|
||||||
renderConversation(ctx, preparedComment, "timeline")
|
renderConversation(ctx, preparedComment, "timeline")
|
||||||
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
|
assert.Contains(t, resp.Body.String(), `<div id="code-comments-`)
|
||||||
})
|
})
|
||||||
|
run("diff non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||||
|
reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{
|
||||||
|
IssueID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
for _, r := range reviews {
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r))
|
||||||
|
}
|
||||||
|
ctx.Data["ShowOutdatedComments"] = true
|
||||||
|
renderConversation(ctx, preparedComment, "diff")
|
||||||
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
|
assert.NotContains(t, resp.Body.String(), `status-page-500`)
|
||||||
|
})
|
||||||
|
run("timeline non-existing review", func(t *testing.T, ctx *context.Context, resp *httptest.ResponseRecorder) {
|
||||||
|
reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{
|
||||||
|
IssueID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
for _, r := range reviews {
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r))
|
||||||
|
}
|
||||||
|
ctx.Data["ShowOutdatedComments"] = true
|
||||||
|
renderConversation(ctx, preparedComment, "timeline")
|
||||||
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
|
assert.NotContains(t, resp.Body.String(), `status-page-500`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
repo_service "code.gitea.io/gitea/services/repository"
|
repo_service "code.gitea.io/gitea/services/repository"
|
||||||
files_service "code.gitea.io/gitea/services/repository/files"
|
files_service "code.gitea.io/gitea/services/repository/files"
|
||||||
|
@ -30,10 +31,24 @@ func TestPullView_ReviewerMissed(t *testing.T) {
|
||||||
session := loginUser(t, "user1")
|
session := loginUser(t, "user1")
|
||||||
|
|
||||||
req := NewRequest(t, "GET", "/pulls")
|
req := NewRequest(t, "GET", "/pulls")
|
||||||
session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
|
||||||
|
|
||||||
req = NewRequest(t, "GET", "/user2/repo1/pulls/3")
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/3")
|
||||||
session.MakeRequest(t, req, http.StatusOK)
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
|
||||||
|
|
||||||
|
// if some reviews are missing, the page shouldn't fail
|
||||||
|
reviews, err := issues_model.FindReviews(db.DefaultContext, issues_model.FindReviewOptions{
|
||||||
|
IssueID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
for _, r := range reviews {
|
||||||
|
assert.NoError(t, issues_model.DeleteReview(db.DefaultContext, r))
|
||||||
|
}
|
||||||
|
req = NewRequest(t, "GET", "/user2/repo1/pulls/2")
|
||||||
|
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadComment(t *testing.T, commentID string) *issues_model.Comment {
|
func loadComment(t *testing.T, commentID string) *issues_model.Comment {
|
||||||
|
|
Loading…
Reference in New Issue