diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-12-29 09:05:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-29 01:05:56 +0000 |
commit | 0ed160ffea91ac1903bd33866fa93c24e3ace65c (patch) | |
tree | 166f0c1c7bbb6e3605c8f06f834a92869bf206bd /routers | |
parent | e95b946f6d763afdb2b68e1f5d7c8b3e518d1986 (diff) | |
download | gitea-0ed160ffea91ac1903bd33866fa93c24e3ace65c.tar.gz gitea-0ed160ffea91ac1903bd33866fa93c24e3ace65c.zip |
Refactor tests (#33021)
1. fix incorrect tests, for example: BeanExists doesn't do assert and
shouldn't be used
2. remove unnecessary test functions
3. introduce DumpQueryResult to help to see the database rows during
test (at least I need it)
```
====== DumpQueryResult: SELECT * FROM action_runner_token ======
- # row[0]
id: 1
token: xeiWBL5kuTYxGPynHCqQdoeYmJAeG3IzGXCYTrDX
owner_id: 0
...
```
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/issue_label_test.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/routers/web/repo/issue_label_test.go b/routers/web/repo/issue_label_test.go index c86a03da51..8a613e2c7e 100644 --- a/routers/web/repo/issue_label_test.go +++ b/routers/web/repo/issue_label_test.go @@ -162,10 +162,11 @@ func TestUpdateIssueLabel_Toggle(t *testing.T) { UpdateIssueLabel(ctx) assert.EqualValues(t, http.StatusOK, ctx.Resp.Status()) for _, issueID := range testCase.IssueIDs { - unittest.AssertExistsIf(t, testCase.ExpectedAdd, &issues_model.IssueLabel{ - IssueID: issueID, - LabelID: testCase.LabelID, - }) + if testCase.ExpectedAdd { + unittest.AssertExistsAndLoadBean(t, &issues_model.IssueLabel{IssueID: issueID, LabelID: testCase.LabelID}) + } else { + unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{IssueID: issueID, LabelID: testCase.LabelID}) + } } unittest.CheckConsistencyFor(t, &issues_model.Label{}) } |