Przeglądaj źródła

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>
tags/v1.22.0-rc0
Lunny Xiao 7 miesięcy temu
rodzic
commit
673cf6af76
No account linked to committer's email address
55 zmienionych plików z 81 dodań i 222 usunięć
  1. 1
    3
      cmd/main_test.go
  2. 1
    4
      models/activities/main_test.go
  3. 0
    2
      models/asymkey/main_test.go
  4. 1
    4
      models/auth/main_test.go
  5. 1
    4
      models/avatars/main_test.go
  6. 1
    4
      models/db/main_test.go
  7. 1
    4
      models/db/paginator/main_test.go
  8. 1
    4
      models/dbfs/main_test.go
  9. 1
    4
      models/git/main_test.go
  10. 1
    4
      models/issues/main_test.go
  11. 1
    3
      models/main_test.go
  12. 1
    4
      models/organization/main_test.go
  13. 1
    4
      models/packages/package_test.go
  14. 1
    4
      models/perm/access/main_test.go
  15. 0
    2
      models/project/main_test.go
  16. 1
    4
      models/repo/main_test.go
  17. 1
    4
      models/system/main_test.go
  18. 32
    21
      models/unittest/testdb.go
  19. 1
    4
      models/user/main_test.go
  20. 0
    2
      models/webhook/main_test.go
  21. 1
    4
      modules/activitypub/main_test.go
  22. 1
    4
      modules/indexer/code/indexer_test.go
  23. 1
    4
      modules/indexer/issues/indexer_test.go
  24. 1
    4
      modules/indexer/stats/indexer_test.go
  25. 1
    4
      modules/repository/main_test.go
  26. 1
    3
      modules/system/appstate_test.go
  27. 0
    2
      routers/api/v1/repo/main_test.go
  28. 1
    4
      routers/common/errpage_test.go
  29. 1
    4
      routers/install/routes_test.go
  30. 1
    4
      routers/private/main_test.go
  31. 1
    4
      routers/web/admin/main_test.go
  32. 1
    4
      routers/web/auth/main_test.go
  33. 1
    4
      routers/web/org/main_test.go
  34. 1
    4
      routers/web/repo/main_test.go
  35. 1
    4
      routers/web/repo/setting/main_test.go
  36. 1
    4
      routers/web/user/main_test.go
  37. 1
    4
      routers/web/user/setting/main_test.go
  38. 1
    4
      services/asymkey/main_test.go
  39. 1
    3
      services/attachment/attachment_test.go
  40. 1
    4
      services/convert/main_test.go
  41. 1
    4
      services/feed/action_test.go
  42. 1
    4
      services/gitdiff/main_test.go
  43. 1
    4
      services/issue/main_test.go
  44. 1
    4
      services/mailer/main_test.go
  45. 1
    3
      services/markup/main_test.go
  46. 1
    4
      services/migrations/main_test.go
  47. 1
    4
      services/org/org_test.go
  48. 1
    4
      services/pull/main_test.go
  49. 1
    4
      services/release/release_test.go
  50. 1
    4
      services/repository/archiver/archiver_test.go
  51. 1
    4
      services/repository/files/content_test.go
  52. 1
    4
      services/repository/main_test.go
  53. 1
    4
      services/user/user_test.go
  54. 0
    2
      services/webhook/main_test.go
  55. 1
    4
      services/wiki/wiki_test.go

+ 1
- 3
cmd/main_test.go Wyświetl plik

@@ -20,9 +20,7 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: "..",
})
unittest.MainTest(m)
}

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

+ 1
- 4
models/activities/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package activities_test

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)
}

+ 0
- 2
models/asymkey/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package asymkey

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{
"gpg_key.yml",
"public_key.yml",

+ 1
- 4
models/auth/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package auth_test

import (
"path/filepath"
"testing"

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

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 1
- 4
models/avatars/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package avatars_test

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)
}

+ 1
- 4
models/db/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package db_test

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)
}

+ 1
- 4
models/db/paginator/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package paginator

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)
}

+ 1
- 4
models/dbfs/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package dbfs

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)
}

+ 1
- 4
models/git/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package git_test

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)
}

+ 1
- 4
models/issues/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package issues_test

import (
"path/filepath"
"testing"

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

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 1
- 3
models/main_test.go Wyświetl plik

@@ -29,7 +29,5 @@ func TestFixturesAreConsistent(t *testing.T) {
}

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: "..",
})
unittest.MainTest(m)
}

+ 1
- 4
models/organization/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package organization_test

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -18,7 +17,5 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 1
- 4
models/packages/package_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package packages_test

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/db"
@@ -20,9 +19,7 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

func TestHasOwnerPackages(t *testing.T) {

+ 1
- 4
models/perm/access/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package access_test

import (
"path/filepath"
"testing"

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

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", ".."),
})
unittest.MainTest(m)
}

+ 0
- 2
models/project/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package project

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -14,7 +13,6 @@ import (

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
FixtureFiles: []string{
"project.yml",
"project_board.yml",

+ 1
- 4
models/repo/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package repo_test

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -18,7 +17,5 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 1
- 4
models/system/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package system_test

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -16,7 +15,5 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 32
- 21
models/unittest/testdb.go Wyświetl plik

@@ -62,35 +62,46 @@ func InitSettings(extraConfigs ...string) {

// TestOptions represents test options
type TestOptions struct {
GiteaRootPath string
FixtureFiles []string
SetUp func() error // SetUp will be executed before all tests in this package
TearDown func() error // TearDown will be executed after all tests in this package
FixtureFiles []string
SetUp func() error // SetUp will be executed before all tests in this package
TearDown func() error // TearDown will be executed after all tests in this package
}

// MainTest a reusable TestMain(..) function for unit tests that need to use a
// test database. Creates the test database, and sets necessary settings.
func MainTest(m *testing.M, testOpts *TestOptions) {
setting.CustomPath = filepath.Join(testOpts.GiteaRootPath, "custom")
InitSettings()

var err error
func MainTest(m *testing.M, testOpts ...*TestOptions) {
searchDir, _ := os.Getwd()
for searchDir != "" {
if _, err := os.Stat(filepath.Join(searchDir, "go.mod")); err == nil {
break // The "go.mod" should be the one for Gitea repository
}
if dir := filepath.Dir(searchDir); dir == searchDir {
searchDir = "" // reaches the root of filesystem
} else {
searchDir = dir
}
}
if searchDir == "" {
panic("The tests should run in a Gitea repository, there should be a 'go.mod' in the root")
}

giteaRoot = testOpts.GiteaRootPath
fixturesDir = filepath.Join(testOpts.GiteaRootPath, "models", "fixtures")
giteaRoot = searchDir
setting.CustomPath = filepath.Join(giteaRoot, "custom")
InitSettings()

fixturesDir = filepath.Join(giteaRoot, "models", "fixtures")
var opts FixturesOptions
if len(testOpts.FixtureFiles) == 0 {
if len(testOpts) == 0 || len(testOpts[0].FixtureFiles) == 0 {
opts.Dir = fixturesDir
} else {
for _, f := range testOpts.FixtureFiles {
for _, f := range testOpts[0].FixtureFiles {
if len(f) != 0 {
opts.Files = append(opts.Files, filepath.Join(fixturesDir, f))
}
}
}

if err = CreateTestEngine(opts); err != nil {
if err := CreateTestEngine(opts); err != nil {
fatalTestError("Error creating test engine: %v\n", err)
}

@@ -112,8 +123,8 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
fatalTestError("TempDir: %v\n", err)
}
setting.AppDataPath = appDataPath
setting.AppWorkPath = testOpts.GiteaRootPath
setting.StaticRootPath = testOpts.GiteaRootPath
setting.AppWorkPath = giteaRoot
setting.StaticRootPath = giteaRoot
setting.GravatarSource = "https://secure.gravatar.com/avatar/"

setting.Attachment.Storage.Path = filepath.Join(setting.AppDataPath, "attachments")
@@ -144,7 +155,7 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
if err = util.RemoveAll(repoRootPath); err != nil {
fatalTestError("util.RemoveAll: %v\n", err)
}
if err = CopyDir(filepath.Join(testOpts.GiteaRootPath, "tests", "gitea-repositories-meta"), setting.RepoRootPath); err != nil {
if err = CopyDir(filepath.Join(giteaRoot, "tests", "gitea-repositories-meta"), setting.RepoRootPath); err != nil {
fatalTestError("util.CopyDir: %v\n", err)
}

@@ -171,16 +182,16 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
}
}

if testOpts.SetUp != nil {
if err := testOpts.SetUp(); err != nil {
if len(testOpts) > 0 && testOpts[0].SetUp != nil {
if err := testOpts[0].SetUp(); err != nil {
fatalTestError("set up failed: %v\n", err)
}
}

exitStatus := m.Run()

if testOpts.TearDown != nil {
if err := testOpts.TearDown(); err != nil {
if len(testOpts) > 0 && testOpts[0].TearDown != nil {
if err := testOpts[0].TearDown(); err != nil {
fatalTestError("tear down failed: %v\n", err)
}
}

+ 1
- 4
models/user/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package user_test

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -16,7 +15,5 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 0
- 2
models/webhook/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package webhook

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{
"webhook.yml",
"hook_task.yml",

+ 1
- 4
modules/activitypub/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package activitypub

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)
}

+ 1
- 4
modules/indexer/code/indexer_test.go Wyświetl plik

@@ -6,7 +6,6 @@ package code
import (
"context"
"os"
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -23,9 +22,7 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", ".."),
})
unittest.MainTest(m)
}

func testIndexer(name string, t *testing.T, indexer internal.Indexer) {

+ 1
- 4
modules/indexer/issues/indexer_test.go Wyświetl plik

@@ -5,7 +5,6 @@ package issues

import (
"context"
"path/filepath"
"testing"

"code.gitea.io/gitea/models/db"
@@ -22,9 +21,7 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", ".."),
})
unittest.MainTest(m)
}

func TestDBSearchIssues(t *testing.T) {

+ 1
- 4
modules/indexer/stats/indexer_test.go Wyświetl plik

@@ -5,7 +5,6 @@ package stats

import (
"context"
"path/filepath"
"testing"
"time"

@@ -23,9 +22,7 @@ import (
)

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", ".."),
})
unittest.MainTest(m)
}

func TestRepoStatsIndex(t *testing.T) {

+ 1
- 4
modules/repository/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package repository

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)
}

+ 1
- 3
modules/system/appstate_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package system

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -14,8 +13,7 @@ import (

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
FixtureFiles: []string{""}, // load nothing
FixtureFiles: []string{""}, // load nothing
})
}


+ 0
- 2
routers/api/v1/repo/main_test.go Wyświetl plik

@@ -4,7 +4,6 @@
package repo

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -14,7 +13,6 @@ import (

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", "..", ".."),
SetUp: func() error {
setting.LoadQueueSettings()
return webhook_service.Init()

+ 1
- 4
routers/common/errpage_test.go Wyświetl plik

@@ -9,7 +9,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -35,7 +34,5 @@ func TestRenderPanicErrorPage(t *testing.T) {
}

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 1
- 4
routers/install/routes_test.go Wyświetl plik

@@ -5,7 +5,6 @@ package install

import (
"net/http/httptest"
"path/filepath"
"testing"

"code.gitea.io/gitea/models/unittest"
@@ -35,7 +34,5 @@ func TestRoutes(t *testing.T) {
}

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", ".."),
})
unittest.MainTest(m)
}

+ 1
- 4
routers/private/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package private

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)
}

+ 1
- 4
routers/web/admin/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package admin

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)
}

+ 1
- 4
routers/web/auth/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package auth

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)
}

+ 1
- 4
routers/web/org/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package org_test

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)
}

+ 1
- 4
routers/web/repo/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package repo

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)
}

+ 1
- 4
routers/web/repo/setting/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package setting

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)
}

+ 1
- 4
routers/web/user/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package user

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)
}

+ 1
- 4
routers/web/user/setting/main_test.go Wyświetl plik

@@ -4,14 +4,11 @@
package setting

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)
}

+ 1
- 4
services/asymkey/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 3
services/attachment/attachment_test.go Wyświetl plik

@@ -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) {

+ 1
- 4
services/convert/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 4
services/feed/action_test.go Wyświetl plik

@@ -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) {

+ 1
- 4
services/gitdiff/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 4
services/issue/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 4
services/mailer/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 3
services/markup/main_test.go Wyświetl plik

@@ -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"},
})
}

+ 1
- 4
services/migrations/main_test.go Wyświetl plik

@@ -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 {

+ 1
- 4
services/org/org_test.go Wyświetl plik

@@ -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) {

+ 1
- 4
services/pull/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 4
services/release/release_test.go Wyświetl plik

@@ -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) {

+ 1
- 4
services/repository/archiver/archiver_test.go Wyświetl plik

@@ -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) {

+ 1
- 4
services/repository/files/content_test.go Wyświetl plik

@@ -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 {

+ 1
- 4
services/repository/main_test.go Wyświetl plik

@@ -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)
}

+ 1
- 4
services/user/user_test.go Wyświetl plik

@@ -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) {

+ 0
- 2
services/webhook/main_test.go Wyświetl plik

@@ -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()

+ 1
- 4
services/wiki/wiki_test.go Wyświetl plik

@@ -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) {

Ładowanie…
Anuluj
Zapisz