chore: improve test quality

- Merge tests together.
- Remove unecessary usage of `onGiteaRun`.
- Make proper use of `unittest`.
- Make proper use of `test.MockVariable`.
- I have not checked all of the testing files yet.
This commit is contained in:
Gusted 2024-11-10 18:25:41 +01:00
parent ab36ab57e4
commit 582ab21bc3
No known key found for this signature in database
GPG key ID: FD821B732837125F
18 changed files with 620 additions and 784 deletions

View file

@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/services/actions"
"code.gitea.io/gitea/services/automerge"
@ -23,7 +24,7 @@ import (
func TestActionsAutomerge(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
assert.True(t, setting.Actions.Enabled, "Actions should be enabled")
defer test.MockVariableValue(&setting.Actions.Enabled, true)()
ctx := db.DefaultContext