Skip to content

Commit 673cf6a

Browse files
lunnywxiaoguang
andauthored
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 <[email protected]>
1 parent e74a3b1 commit 673cf6a

File tree

55 files changed

+81
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+81
-222
lines changed

cmd/main_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ import (
2020
)
2121

2222
func TestMain(m *testing.M) {
23-
unittest.MainTest(m, &unittest.TestOptions{
24-
GiteaRootPath: "..",
25-
})
23+
unittest.MainTest(m)
2624
}
2725

2826
func makePathOutput(workPath, customPath, customConf string) string {

models/activities/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package activities_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
@@ -14,7 +13,5 @@ import (
1413
)
1514

1615
func TestMain(m *testing.M) {
17-
unittest.MainTest(m, &unittest.TestOptions{
18-
GiteaRootPath: filepath.Join("..", ".."),
19-
})
16+
unittest.MainTest(m)
2017
}

models/asymkey/main_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
package asymkey
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
1110
)
1211

1312
func TestMain(m *testing.M) {
1413
unittest.MainTest(m, &unittest.TestOptions{
15-
GiteaRootPath: filepath.Join("..", ".."),
1614
FixtureFiles: []string{
1715
"gpg_key.yml",
1816
"public_key.yml",

models/auth/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package auth_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
@@ -17,7 +16,5 @@ import (
1716
)
1817

1918
func TestMain(m *testing.M) {
20-
unittest.MainTest(m, &unittest.TestOptions{
21-
GiteaRootPath: filepath.Join("..", ".."),
22-
})
19+
unittest.MainTest(m)
2320
}

models/avatars/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package avatars_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
@@ -15,7 +14,5 @@ import (
1514
)
1615

1716
func TestMain(m *testing.M) {
18-
unittest.MainTest(m, &unittest.TestOptions{
19-
GiteaRootPath: filepath.Join("..", ".."),
20-
})
17+
unittest.MainTest(m)
2118
}

models/db/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package db_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
@@ -14,7 +13,5 @@ import (
1413
)
1514

1615
func TestMain(m *testing.M) {
17-
unittest.MainTest(m, &unittest.TestOptions{
18-
GiteaRootPath: filepath.Join("..", ".."),
19-
})
16+
unittest.MainTest(m)
2017
}

models/db/paginator/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
package paginator
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
1110
)
1211

1312
func TestMain(m *testing.M) {
14-
unittest.MainTest(m, &unittest.TestOptions{
15-
GiteaRootPath: filepath.Join("..", "..", ".."),
16-
})
13+
unittest.MainTest(m)
1714
}

models/dbfs/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
package dbfs
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
1110
)
1211

1312
func TestMain(m *testing.M) {
14-
unittest.MainTest(m, &unittest.TestOptions{
15-
GiteaRootPath: filepath.Join("..", ".."),
16-
})
13+
unittest.MainTest(m)
1714
}

models/git/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package git_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
"code.gitea.io/gitea/models/unittest"
@@ -15,7 +14,5 @@ import (
1514
)
1615

1716
func TestMain(m *testing.M) {
18-
unittest.MainTest(m, &unittest.TestOptions{
19-
GiteaRootPath: filepath.Join("..", ".."),
20-
})
17+
unittest.MainTest(m)
2118
}

models/issues/main_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package issues_test
55

66
import (
7-
"path/filepath"
87
"testing"
98

109
issues_model "code.gitea.io/gitea/models/issues"
@@ -30,7 +29,5 @@ func TestFixturesAreConsistent(t *testing.T) {
3029
}
3130

3231
func TestMain(m *testing.M) {
33-
unittest.MainTest(m, &unittest.TestOptions{
34-
GiteaRootPath: filepath.Join("..", ".."),
35-
})
32+
unittest.MainTest(m)
3633
}

0 commit comments

Comments
 (0)