summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-09-28 09:38:53 +0800
committerGitHub <noreply@github.com>2023-09-28 01:38:53 +0000
commit673cf6af763fe7fd4301382f7b059b0799fca396 (patch)
treee9d0ed0f9d6af5dd03841c3126c9c8c0544b1277 /services
parente74a3b18afdbe9bbf56b8f845c915c13894d15c3 (diff)
downloadgitea-673cf6af763fe7fd4301382f7b059b0799fca396.tar.gz
gitea-673cf6af763fe7fd4301382f7b059b0799fca396.zip
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>
Diffstat (limited to 'services')
-rw-r--r--services/asymkey/main_test.go5
-rw-r--r--services/attachment/attachment_test.go4
-rw-r--r--services/convert/main_test.go5
-rw-r--r--services/feed/action_test.go5
-rw-r--r--services/gitdiff/main_test.go5
-rw-r--r--services/issue/main_test.go5
-rw-r--r--services/mailer/main_test.go5
-rw-r--r--services/markup/main_test.go4
-rw-r--r--services/migrations/main_test.go5
-rw-r--r--services/org/org_test.go5
-rw-r--r--services/pull/main_test.go5
-rw-r--r--services/release/release_test.go5
-rw-r--r--services/repository/archiver/archiver_test.go5
-rw-r--r--services/repository/files/content_test.go5
-rw-r--r--services/repository/main_test.go5
-rw-r--r--services/user/user_test.go5
-rw-r--r--services/webhook/main_test.go2
-rw-r--r--services/wiki/wiki_test.go5
18 files changed, 17 insertions, 68 deletions
diff --git a/services/asymkey/main_test.go b/services/asymkey/main_test.go
index e7a03861b9..3505b26f69 100644
--- a/services/asymkey/main_test.go
+++ b/services/asymkey/main_test.go
@@ -4,7 +4,6 @@
package asymkey
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -14,7 +13,5 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/attachment/attachment_test.go b/services/attachment/attachment_test.go
index 35fcef7445..77ef1cd37c 100644
--- a/services/attachment/attachment_test.go
+++ b/services/attachment/attachment_test.go
@@ -19,9 +19,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func TestUploadAttachment(t *testing.T) {
diff --git a/services/convert/main_test.go b/services/convert/main_test.go
index c2298dcb74..363cc4a97f 100644
--- a/services/convert/main_test.go
+++ b/services/convert/main_test.go
@@ -4,7 +4,6 @@
package convert
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -13,7 +12,5 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/feed/action_test.go b/services/feed/action_test.go
index fd84bb675b..e1b071d8f6 100644
--- a/services/feed/action_test.go
+++ b/services/feed/action_test.go
@@ -4,7 +4,6 @@
package feed
import (
- "path/filepath"
"strings"
"testing"
@@ -20,9 +19,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func TestRenameRepoAction(t *testing.T) {
diff --git a/services/gitdiff/main_test.go b/services/gitdiff/main_test.go
index 7f4243576c..cd9dcd8cd6 100644
--- a/services/gitdiff/main_test.go
+++ b/services/gitdiff/main_test.go
@@ -4,7 +4,6 @@
package gitdiff
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -15,7 +14,5 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/issue/main_test.go b/services/issue/main_test.go
index 6bce694cca..5dac54183b 100644
--- a/services/issue/main_test.go
+++ b/services/issue/main_test.go
@@ -4,7 +4,6 @@
package issue
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -13,7 +12,5 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/mailer/main_test.go b/services/mailer/main_test.go
index e906f4cb6e..f803c736ca 100644
--- a/services/mailer/main_test.go
+++ b/services/mailer/main_test.go
@@ -4,7 +4,6 @@
package mailer
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -13,7 +12,5 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/markup/main_test.go b/services/markup/main_test.go
index ce892435a1..89fe3e7e34 100644
--- a/services/markup/main_test.go
+++ b/services/markup/main_test.go
@@ -4,7 +4,6 @@
package markup
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -12,7 +11,6 @@ import (
func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- FixtureFiles: []string{"user.yml"},
+ FixtureFiles: []string{"user.yml"},
})
}
diff --git a/services/migrations/main_test.go b/services/migrations/main_test.go
index 42c433fb00..d0ec6a3f8d 100644
--- a/services/migrations/main_test.go
+++ b/services/migrations/main_test.go
@@ -5,7 +5,6 @@
package migrations
import (
- "path/filepath"
"testing"
"time"
@@ -16,9 +15,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func timePtr(t time.Time) *time.Time {
diff --git a/services/org/org_test.go b/services/org/org_test.go
index cc22595c6f..339646795d 100644
--- a/services/org/org_test.go
+++ b/services/org/org_test.go
@@ -4,7 +4,6 @@
package org
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models"
@@ -16,9 +15,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func TestDeleteOrganization(t *testing.T) {
diff --git a/services/pull/main_test.go b/services/pull/main_test.go
index f5297354d6..efbb63a36e 100644
--- a/services/pull/main_test.go
+++ b/services/pull/main_test.go
@@ -5,7 +5,6 @@
package pull
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -14,7 +13,5 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/release/release_test.go b/services/release/release_test.go
index 9c652f28d2..3f0c67b0e0 100644
--- a/services/release/release_test.go
+++ b/services/release/release_test.go
@@ -4,7 +4,6 @@
package release
import (
- "path/filepath"
"strings"
"testing"
"time"
@@ -22,9 +21,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func TestRelease_Create(t *testing.T) {
diff --git a/services/repository/archiver/archiver_test.go b/services/repository/archiver/archiver_test.go
index a1bc355d4e..ff8bb8ca7a 100644
--- a/services/repository/archiver/archiver_test.go
+++ b/services/repository/archiver/archiver_test.go
@@ -5,7 +5,6 @@ package archiver
import (
"errors"
- "path/filepath"
"testing"
"time"
@@ -18,9 +17,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", "..", ".."),
- })
+ unittest.MainTest(m)
}
func TestArchive_Basic(t *testing.T) {
diff --git a/services/repository/files/content_test.go b/services/repository/files/content_test.go
index d591c46839..3ad3e3ab98 100644
--- a/services/repository/files/content_test.go
+++ b/services/repository/files/content_test.go
@@ -4,7 +4,6 @@
package files
import (
- "path/filepath"
"testing"
repo_model "code.gitea.io/gitea/models/repo"
@@ -19,9 +18,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", "..", ".."),
- })
+ unittest.MainTest(m)
}
func getExpectedReadmeContentsResponse() *api.ContentsResponse {
diff --git a/services/repository/main_test.go b/services/repository/main_test.go
index 007790f2a9..7ad1540aee 100644
--- a/services/repository/main_test.go
+++ b/services/repository/main_test.go
@@ -4,14 +4,11 @@
package repository
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
diff --git a/services/user/user_test.go b/services/user/user_test.go
index b8f7b9b1a2..550dafd9c5 100644
--- a/services/user/user_test.go
+++ b/services/user/user_test.go
@@ -5,7 +5,6 @@ package user
import (
"fmt"
- "path/filepath"
"strings"
"testing"
@@ -22,9 +21,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func TestDeleteUser(t *testing.T) {
diff --git a/services/webhook/main_test.go b/services/webhook/main_test.go
index cd34c02b5c..756b9db230 100644
--- a/services/webhook/main_test.go
+++ b/services/webhook/main_test.go
@@ -4,7 +4,6 @@
package webhook
import (
- "path/filepath"
"testing"
"code.gitea.io/gitea/models/unittest"
@@ -19,7 +18,6 @@ func TestMain(m *testing.M) {
// for tests, allow only loopback IPs
setting.Webhook.AllowedHostList = hostmatcher.MatchBuiltinLoopback
unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
SetUp: func() error {
setting.LoadQueueSettings()
return Init()
diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go
index 81a688b046..e8da176a08 100644
--- a/services/wiki/wiki_test.go
+++ b/services/wiki/wiki_test.go
@@ -5,7 +5,6 @@ package wiki
import (
"math/rand"
- "path/filepath"
"strings"
"testing"
@@ -20,9 +19,7 @@ import (
)
func TestMain(m *testing.M) {
- unittest.MainTest(m, &unittest.TestOptions{
- GiteaRootPath: filepath.Join("..", ".."),
- })
+ unittest.MainTest(m)
}
func TestWebPathSegments(t *testing.T) {