loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

make writing main test easier (#27270)

This PR removed `unittest.MainTest` the second parameter
`TestOptions.GiteaRoot`. Now it detects the root directory by current
working directory.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

authored by

Lunny Xiao
wxiaoguang
and committed by
GitHub
673cf6af e74a3b18

+81 -222
+1 -3
cmd/main_test.go
··· 20 20 ) 21 21 22 22 func TestMain(m *testing.M) { 23 - unittest.MainTest(m, &unittest.TestOptions{ 24 - GiteaRootPath: "..", 25 - }) 23 + unittest.MainTest(m) 26 24 } 27 25 28 26 func makePathOutput(workPath, customPath, customConf string) string {
+1 -4
models/activities/main_test.go
··· 4 4 package activities_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 14 13 ) 15 14 16 15 func TestMain(m *testing.M) { 17 - unittest.MainTest(m, &unittest.TestOptions{ 18 - GiteaRootPath: filepath.Join("..", ".."), 19 - }) 16 + unittest.MainTest(m) 20 17 }
-2
models/asymkey/main_test.go
··· 4 4 package asymkey 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 12 11 13 12 func TestMain(m *testing.M) { 14 13 unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", ".."), 16 14 FixtureFiles: []string{ 17 15 "gpg_key.yml", 18 16 "public_key.yml",
+1 -4
models/auth/main_test.go
··· 4 4 package auth_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 17 16 ) 18 17 19 18 func TestMain(m *testing.M) { 20 - unittest.MainTest(m, &unittest.TestOptions{ 21 - GiteaRootPath: filepath.Join("..", ".."), 22 - }) 19 + unittest.MainTest(m) 23 20 }
+1 -4
models/avatars/main_test.go
··· 4 4 package avatars_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 15 14 ) 16 15 17 16 func TestMain(m *testing.M) { 18 - unittest.MainTest(m, &unittest.TestOptions{ 19 - GiteaRootPath: filepath.Join("..", ".."), 20 - }) 17 + unittest.MainTest(m) 21 18 }
+1 -4
models/db/main_test.go
··· 4 4 package db_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 14 13 ) 15 14 16 15 func TestMain(m *testing.M) { 17 - unittest.MainTest(m, &unittest.TestOptions{ 18 - GiteaRootPath: filepath.Join("..", ".."), 19 - }) 16 + unittest.MainTest(m) 20 17 }
+1 -4
models/db/paginator/main_test.go
··· 4 4 package paginator 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
models/dbfs/main_test.go
··· 4 4 package dbfs 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
models/git/main_test.go
··· 4 4 package git_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 15 14 ) 16 15 17 16 func TestMain(m *testing.M) { 18 - unittest.MainTest(m, &unittest.TestOptions{ 19 - GiteaRootPath: filepath.Join("..", ".."), 20 - }) 17 + unittest.MainTest(m) 21 18 }
+1 -4
models/issues/main_test.go
··· 4 4 package issues_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 issues_model "code.gitea.io/gitea/models/issues" ··· 30 29 } 31 30 32 31 func TestMain(m *testing.M) { 33 - unittest.MainTest(m, &unittest.TestOptions{ 34 - GiteaRootPath: filepath.Join("..", ".."), 35 - }) 32 + unittest.MainTest(m) 36 33 }
+1 -3
models/main_test.go
··· 29 29 } 30 30 31 31 func TestMain(m *testing.M) { 32 - unittest.MainTest(m, &unittest.TestOptions{ 33 - GiteaRootPath: "..", 34 - }) 32 + unittest.MainTest(m) 35 33 }
+1 -4
models/organization/main_test.go
··· 4 4 package organization_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 18 17 ) 19 18 20 19 func TestMain(m *testing.M) { 21 - unittest.MainTest(m, &unittest.TestOptions{ 22 - GiteaRootPath: filepath.Join("..", ".."), 23 - }) 20 + unittest.MainTest(m) 24 21 }
+1 -4
models/packages/package_test.go
··· 4 4 package packages_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/db" ··· 20 19 ) 21 20 22 21 func TestMain(m *testing.M) { 23 - unittest.MainTest(m, &unittest.TestOptions{ 24 - GiteaRootPath: filepath.Join("..", ".."), 25 - }) 22 + unittest.MainTest(m) 26 23 } 27 24 28 25 func TestHasOwnerPackages(t *testing.T) {
+1 -4
models/perm/access/main_test.go
··· 4 4 package access_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 17 16 ) 18 17 19 18 func TestMain(m *testing.M) { 20 - unittest.MainTest(m, &unittest.TestOptions{ 21 - GiteaRootPath: filepath.Join("..", "..", ".."), 22 - }) 19 + unittest.MainTest(m) 23 20 }
-2
models/project/main_test.go
··· 4 4 package project 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 14 13 15 14 func TestMain(m *testing.M) { 16 15 unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", ".."), 18 16 FixtureFiles: []string{ 19 17 "project.yml", 20 18 "project_board.yml",
+1 -4
models/repo/main_test.go
··· 4 4 package repo_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 18 17 ) 19 18 20 19 func TestMain(m *testing.M) { 21 - unittest.MainTest(m, &unittest.TestOptions{ 22 - GiteaRootPath: filepath.Join("..", ".."), 23 - }) 20 + unittest.MainTest(m) 24 21 }
+1 -4
models/system/main_test.go
··· 4 4 package system_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 16 15 ) 17 16 18 17 func TestMain(m *testing.M) { 19 - unittest.MainTest(m, &unittest.TestOptions{ 20 - GiteaRootPath: filepath.Join("..", ".."), 21 - }) 18 + unittest.MainTest(m) 22 19 }
+32 -21
models/unittest/testdb.go
··· 62 62 63 63 // TestOptions represents test options 64 64 type TestOptions struct { 65 - GiteaRootPath string 66 - FixtureFiles []string 67 - SetUp func() error // SetUp will be executed before all tests in this package 68 - TearDown func() error // TearDown will be executed after all tests in this package 65 + FixtureFiles []string 66 + SetUp func() error // SetUp will be executed before all tests in this package 67 + TearDown func() error // TearDown will be executed after all tests in this package 69 68 } 70 69 71 70 // MainTest a reusable TestMain(..) function for unit tests that need to use a 72 71 // test database. Creates the test database, and sets necessary settings. 73 - func MainTest(m *testing.M, testOpts *TestOptions) { 74 - setting.CustomPath = filepath.Join(testOpts.GiteaRootPath, "custom") 72 + func MainTest(m *testing.M, testOpts ...*TestOptions) { 73 + searchDir, _ := os.Getwd() 74 + for searchDir != "" { 75 + if _, err := os.Stat(filepath.Join(searchDir, "go.mod")); err == nil { 76 + break // The "go.mod" should be the one for Gitea repository 77 + } 78 + if dir := filepath.Dir(searchDir); dir == searchDir { 79 + searchDir = "" // reaches the root of filesystem 80 + } else { 81 + searchDir = dir 82 + } 83 + } 84 + if searchDir == "" { 85 + panic("The tests should run in a Gitea repository, there should be a 'go.mod' in the root") 86 + } 87 + 88 + giteaRoot = searchDir 89 + setting.CustomPath = filepath.Join(giteaRoot, "custom") 75 90 InitSettings() 76 91 77 - var err error 78 - 79 - giteaRoot = testOpts.GiteaRootPath 80 - fixturesDir = filepath.Join(testOpts.GiteaRootPath, "models", "fixtures") 81 - 92 + fixturesDir = filepath.Join(giteaRoot, "models", "fixtures") 82 93 var opts FixturesOptions 83 - if len(testOpts.FixtureFiles) == 0 { 94 + if len(testOpts) == 0 || len(testOpts[0].FixtureFiles) == 0 { 84 95 opts.Dir = fixturesDir 85 96 } else { 86 - for _, f := range testOpts.FixtureFiles { 97 + for _, f := range testOpts[0].FixtureFiles { 87 98 if len(f) != 0 { 88 99 opts.Files = append(opts.Files, filepath.Join(fixturesDir, f)) 89 100 } 90 101 } 91 102 } 92 103 93 - if err = CreateTestEngine(opts); err != nil { 104 + if err := CreateTestEngine(opts); err != nil { 94 105 fatalTestError("Error creating test engine: %v\n", err) 95 106 } 96 107 ··· 112 123 fatalTestError("TempDir: %v\n", err) 113 124 } 114 125 setting.AppDataPath = appDataPath 115 - setting.AppWorkPath = testOpts.GiteaRootPath 116 - setting.StaticRootPath = testOpts.GiteaRootPath 126 + setting.AppWorkPath = giteaRoot 127 + setting.StaticRootPath = giteaRoot 117 128 setting.GravatarSource = "https://secure.gravatar.com/avatar/" 118 129 119 130 setting.Attachment.Storage.Path = filepath.Join(setting.AppDataPath, "attachments") ··· 144 155 if err = util.RemoveAll(repoRootPath); err != nil { 145 156 fatalTestError("util.RemoveAll: %v\n", err) 146 157 } 147 - if err = CopyDir(filepath.Join(testOpts.GiteaRootPath, "tests", "gitea-repositories-meta"), setting.RepoRootPath); err != nil { 158 + if err = CopyDir(filepath.Join(giteaRoot, "tests", "gitea-repositories-meta"), setting.RepoRootPath); err != nil { 148 159 fatalTestError("util.CopyDir: %v\n", err) 149 160 } 150 161 ··· 171 182 } 172 183 } 173 184 174 - if testOpts.SetUp != nil { 175 - if err := testOpts.SetUp(); err != nil { 185 + if len(testOpts) > 0 && testOpts[0].SetUp != nil { 186 + if err := testOpts[0].SetUp(); err != nil { 176 187 fatalTestError("set up failed: %v\n", err) 177 188 } 178 189 } 179 190 180 191 exitStatus := m.Run() 181 192 182 - if testOpts.TearDown != nil { 183 - if err := testOpts.TearDown(); err != nil { 193 + if len(testOpts) > 0 && testOpts[0].TearDown != nil { 194 + if err := testOpts[0].TearDown(); err != nil { 184 195 fatalTestError("tear down failed: %v\n", err) 185 196 } 186 197 }
+1 -4
models/user/main_test.go
··· 4 4 package user_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 16 15 ) 17 16 18 17 func TestMain(m *testing.M) { 19 - unittest.MainTest(m, &unittest.TestOptions{ 20 - GiteaRootPath: filepath.Join("..", ".."), 21 - }) 18 + unittest.MainTest(m) 22 19 }
-2
models/webhook/main_test.go
··· 4 4 package webhook 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 12 11 13 12 func TestMain(m *testing.M) { 14 13 unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", ".."), 16 14 FixtureFiles: []string{ 17 15 "webhook.yml", 18 16 "hook_task.yml",
+1 -4
modules/activitypub/main_test.go
··· 4 4 package activitypub 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 15 14 ) 16 15 17 16 func TestMain(m *testing.M) { 18 - unittest.MainTest(m, &unittest.TestOptions{ 19 - GiteaRootPath: filepath.Join("..", ".."), 20 - }) 17 + unittest.MainTest(m) 21 18 }
+1 -4
modules/indexer/code/indexer_test.go
··· 6 6 import ( 7 7 "context" 8 8 "os" 9 - "path/filepath" 10 9 "testing" 11 10 12 11 "code.gitea.io/gitea/models/unittest" ··· 23 22 ) 24 23 25 24 func TestMain(m *testing.M) { 26 - unittest.MainTest(m, &unittest.TestOptions{ 27 - GiteaRootPath: filepath.Join("..", "..", ".."), 28 - }) 25 + unittest.MainTest(m) 29 26 } 30 27 31 28 func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
+1 -4
modules/indexer/issues/indexer_test.go
··· 5 5 6 6 import ( 7 7 "context" 8 - "path/filepath" 9 8 "testing" 10 9 11 10 "code.gitea.io/gitea/models/db" ··· 22 21 ) 23 22 24 23 func TestMain(m *testing.M) { 25 - unittest.MainTest(m, &unittest.TestOptions{ 26 - GiteaRootPath: filepath.Join("..", "..", ".."), 27 - }) 24 + unittest.MainTest(m) 28 25 } 29 26 30 27 func TestDBSearchIssues(t *testing.T) {
+1 -4
modules/indexer/stats/indexer_test.go
··· 5 5 6 6 import ( 7 7 "context" 8 - "path/filepath" 9 8 "testing" 10 9 "time" 11 10 ··· 23 22 ) 24 23 25 24 func TestMain(m *testing.M) { 26 - unittest.MainTest(m, &unittest.TestOptions{ 27 - GiteaRootPath: filepath.Join("..", "..", ".."), 28 - }) 25 + unittest.MainTest(m) 29 26 } 30 27 31 28 func TestRepoStatsIndex(t *testing.T) {
+1 -4
modules/repository/main_test.go
··· 4 4 package repository 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 13 12 ) 14 13 15 14 func TestMain(m *testing.M) { 16 - unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", ".."), 18 - }) 15 + unittest.MainTest(m) 19 16 }
+1 -3
modules/system/appstate_test.go
··· 4 4 package system 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 14 13 15 14 func TestMain(m *testing.M) { 16 15 unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", ".."), 18 - FixtureFiles: []string{""}, // load nothing 16 + FixtureFiles: []string{""}, // load nothing 19 17 }) 20 18 } 21 19
-2
routers/api/v1/repo/main_test.go
··· 4 4 package repo 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 14 13 15 14 func TestMain(m *testing.M) { 16 15 unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", "..", "..", ".."), 18 16 SetUp: func() error { 19 17 setting.LoadQueueSettings() 20 18 return webhook_service.Init()
+1 -4
routers/common/errpage_test.go
··· 9 9 "net/http" 10 10 "net/http/httptest" 11 11 "net/url" 12 - "path/filepath" 13 12 "testing" 14 13 15 14 "code.gitea.io/gitea/models/unittest" ··· 35 34 } 36 35 37 36 func TestMain(m *testing.M) { 38 - unittest.MainTest(m, &unittest.TestOptions{ 39 - GiteaRootPath: filepath.Join("..", ".."), 40 - }) 37 + unittest.MainTest(m) 41 38 }
+1 -4
routers/install/routes_test.go
··· 5 5 6 6 import ( 7 7 "net/http/httptest" 8 - "path/filepath" 9 8 "testing" 10 9 11 10 "code.gitea.io/gitea/models/unittest" ··· 35 34 } 36 35 37 36 func TestMain(m *testing.M) { 38 - unittest.MainTest(m, &unittest.TestOptions{ 39 - GiteaRootPath: filepath.Join("..", ".."), 40 - }) 37 + unittest.MainTest(m) 41 38 }
+1 -4
routers/private/main_test.go
··· 4 4 package private 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/admin/main_test.go
··· 4 4 package admin 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/auth/main_test.go
··· 4 4 package auth 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/org/main_test.go
··· 4 4 package org_test 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/repo/main_test.go
··· 4 4 package repo 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/repo/setting/main_test.go
··· 4 4 package setting 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/user/main_test.go
··· 4 4 package user 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
routers/web/user/setting/main_test.go
··· 4 4 package setting 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", "..", "..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
services/asymkey/main_test.go
··· 4 4 package asymkey 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 14 13 ) 15 14 16 15 func TestMain(m *testing.M) { 17 - unittest.MainTest(m, &unittest.TestOptions{ 18 - GiteaRootPath: filepath.Join("..", ".."), 19 - }) 16 + unittest.MainTest(m) 20 17 }
+1 -3
services/attachment/attachment_test.go
··· 19 19 ) 20 20 21 21 func TestMain(m *testing.M) { 22 - unittest.MainTest(m, &unittest.TestOptions{ 23 - GiteaRootPath: filepath.Join("..", ".."), 24 - }) 22 + unittest.MainTest(m) 25 23 } 26 24 27 25 func TestUploadAttachment(t *testing.T) {
+1 -4
services/convert/main_test.go
··· 4 4 package convert 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 13 12 ) 14 13 15 14 func TestMain(m *testing.M) { 16 - unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", ".."), 18 - }) 15 + unittest.MainTest(m) 19 16 }
+1 -4
services/feed/action_test.go
··· 4 4 package feed 5 5 6 6 import ( 7 - "path/filepath" 8 7 "strings" 9 8 "testing" 10 9 ··· 20 19 ) 21 20 22 21 func TestMain(m *testing.M) { 23 - unittest.MainTest(m, &unittest.TestOptions{ 24 - GiteaRootPath: filepath.Join("..", ".."), 25 - }) 22 + unittest.MainTest(m) 26 23 } 27 24 28 25 func TestRenameRepoAction(t *testing.T) {
+1 -4
services/gitdiff/main_test.go
··· 4 4 package gitdiff 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 15 14 ) 16 15 17 16 func TestMain(m *testing.M) { 18 - unittest.MainTest(m, &unittest.TestOptions{ 19 - GiteaRootPath: filepath.Join("..", ".."), 20 - }) 17 + unittest.MainTest(m) 21 18 }
+1 -4
services/issue/main_test.go
··· 4 4 package issue 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 13 12 ) 14 13 15 14 func TestMain(m *testing.M) { 16 - unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", ".."), 18 - }) 15 + unittest.MainTest(m) 19 16 }
+1 -4
services/mailer/main_test.go
··· 4 4 package mailer 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 13 12 ) 14 13 15 14 func TestMain(m *testing.M) { 16 - unittest.MainTest(m, &unittest.TestOptions{ 17 - GiteaRootPath: filepath.Join("..", ".."), 18 - }) 15 + unittest.MainTest(m) 19 16 }
+1 -3
services/markup/main_test.go
··· 4 4 package markup 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 12 11 13 12 func TestMain(m *testing.M) { 14 13 unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", ".."), 16 - FixtureFiles: []string{"user.yml"}, 14 + FixtureFiles: []string{"user.yml"}, 17 15 }) 18 16 }
+1 -4
services/migrations/main_test.go
··· 5 5 package migrations 6 6 7 7 import ( 8 - "path/filepath" 9 8 "testing" 10 9 "time" 11 10 ··· 16 15 ) 17 16 18 17 func TestMain(m *testing.M) { 19 - unittest.MainTest(m, &unittest.TestOptions{ 20 - GiteaRootPath: filepath.Join("..", ".."), 21 - }) 18 + unittest.MainTest(m) 22 19 } 23 20 24 21 func timePtr(t time.Time) *time.Time {
+1 -4
services/org/org_test.go
··· 4 4 package org 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models" ··· 16 15 ) 17 16 18 17 func TestMain(m *testing.M) { 19 - unittest.MainTest(m, &unittest.TestOptions{ 20 - GiteaRootPath: filepath.Join("..", ".."), 21 - }) 18 + unittest.MainTest(m) 22 19 } 23 20 24 21 func TestDeleteOrganization(t *testing.T) {
+1 -4
services/pull/main_test.go
··· 5 5 package pull 6 6 7 7 import ( 8 - "path/filepath" 9 8 "testing" 10 9 11 10 "code.gitea.io/gitea/models/unittest" ··· 14 13 ) 15 14 16 15 func TestMain(m *testing.M) { 17 - unittest.MainTest(m, &unittest.TestOptions{ 18 - GiteaRootPath: filepath.Join("..", ".."), 19 - }) 16 + unittest.MainTest(m) 20 17 }
+1 -4
services/release/release_test.go
··· 4 4 package release 5 5 6 6 import ( 7 - "path/filepath" 8 7 "strings" 9 8 "testing" 10 9 "time" ··· 22 21 ) 23 22 24 23 func TestMain(m *testing.M) { 25 - unittest.MainTest(m, &unittest.TestOptions{ 26 - GiteaRootPath: filepath.Join("..", ".."), 27 - }) 24 + unittest.MainTest(m) 28 25 } 29 26 30 27 func TestRelease_Create(t *testing.T) {
+1 -4
services/repository/archiver/archiver_test.go
··· 5 5 6 6 import ( 7 7 "errors" 8 - "path/filepath" 9 8 "testing" 10 9 "time" 11 10 ··· 18 17 ) 19 18 20 19 func TestMain(m *testing.M) { 21 - unittest.MainTest(m, &unittest.TestOptions{ 22 - GiteaRootPath: filepath.Join("..", "..", ".."), 23 - }) 20 + unittest.MainTest(m) 24 21 } 25 22 26 23 func TestArchive_Basic(t *testing.T) {
+1 -4
services/repository/files/content_test.go
··· 4 4 package files 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 repo_model "code.gitea.io/gitea/models/repo" ··· 19 18 ) 20 19 21 20 func TestMain(m *testing.M) { 22 - unittest.MainTest(m, &unittest.TestOptions{ 23 - GiteaRootPath: filepath.Join("..", "..", ".."), 24 - }) 21 + unittest.MainTest(m) 25 22 } 26 23 27 24 func getExpectedReadmeContentsResponse() *api.ContentsResponse {
+1 -4
services/repository/main_test.go
··· 4 4 package repository 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" 11 10 ) 12 11 13 12 func TestMain(m *testing.M) { 14 - unittest.MainTest(m, &unittest.TestOptions{ 15 - GiteaRootPath: filepath.Join("..", ".."), 16 - }) 13 + unittest.MainTest(m) 17 14 }
+1 -4
services/user/user_test.go
··· 5 5 6 6 import ( 7 7 "fmt" 8 - "path/filepath" 9 8 "strings" 10 9 "testing" 11 10 ··· 22 21 ) 23 22 24 23 func TestMain(m *testing.M) { 25 - unittest.MainTest(m, &unittest.TestOptions{ 26 - GiteaRootPath: filepath.Join("..", ".."), 27 - }) 24 + unittest.MainTest(m) 28 25 } 29 26 30 27 func TestDeleteUser(t *testing.T) {
-2
services/webhook/main_test.go
··· 4 4 package webhook 5 5 6 6 import ( 7 - "path/filepath" 8 7 "testing" 9 8 10 9 "code.gitea.io/gitea/models/unittest" ··· 19 18 // for tests, allow only loopback IPs 20 19 setting.Webhook.AllowedHostList = hostmatcher.MatchBuiltinLoopback 21 20 unittest.MainTest(m, &unittest.TestOptions{ 22 - GiteaRootPath: filepath.Join("..", ".."), 23 21 SetUp: func() error { 24 22 setting.LoadQueueSettings() 25 23 return Init()
+1 -4
services/wiki/wiki_test.go
··· 5 5 6 6 import ( 7 7 "math/rand" 8 - "path/filepath" 9 8 "strings" 10 9 "testing" 11 10 ··· 20 19 ) 21 20 22 21 func TestMain(m *testing.M) { 23 - unittest.MainTest(m, &unittest.TestOptions{ 24 - GiteaRootPath: filepath.Join("..", ".."), 25 - }) 22 + unittest.MainTest(m) 26 23 } 27 24 28 25 func TestWebPathSegments(t *testing.T) {