mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-03 10:14:30 +00:00
chore: clean up tests (#37715)
1. use MockVariableValue as much as possible 2. use wg.Go as much as possible instead of Add/Done 3. simplify global lock's DefaultLocker logic to make it easier to test 4. introduce a general approach for getting external service config in CI 5. remove unclear & unnecessary "t.Skip" 6. use modern generic syntax for remaining "DecodeJSON" calls 7. clarify test result for "list gitignore templates" and "list licenses"
This commit is contained in:
@@ -28,8 +28,7 @@ import (
|
||||
|
||||
func TestAPILFSNotStarted(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = false
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, false)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
@@ -48,8 +47,7 @@ func TestAPILFSNotStarted(t *testing.T) {
|
||||
|
||||
func TestAPILFSMediaType(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
@@ -72,8 +70,7 @@ func createLFSTestRepository(t *testing.T, repoName string) *repo_model.Reposito
|
||||
|
||||
func TestAPILFSBatch(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
repo := createLFSTestRepository(t, "lfs-batch-repo")
|
||||
|
||||
@@ -326,8 +323,7 @@ func TestAPILFSBatch(t *testing.T) {
|
||||
|
||||
func TestAPILFSUpload(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
repo := createLFSTestRepository(t, "lfs-upload-repo")
|
||||
oid := storeObjectInRepo(t, repo.ID, "dummy3")
|
||||
@@ -428,8 +424,7 @@ func TestAPILFSUpload(t *testing.T) {
|
||||
|
||||
func TestAPILFSVerify(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
repo := createLFSTestRepository(t, "lfs-verify-repo")
|
||||
oid := storeObjectInRepo(t, repo.ID, "dummy3")
|
||||
|
||||
Reference in New Issue
Block a user