diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/e2e/e2e_test.go | 2 | ||||
-rw-r--r-- | tests/integration/integration_test.go | 2 | ||||
-rw-r--r-- | tests/integration/migration-test/migration_test.go | 8 | ||||
-rw-r--r-- | tests/test_utils.go | 6 |
4 files changed, 10 insertions, 8 deletions
diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index e75b3db38f..fbcb0e7da5 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -31,7 +31,7 @@ import ( var c *web.Route func TestMain(m *testing.M) { - defer log.Close() + defer log.GetManager().Close() managerCtx, cancel := context.WithCancel(context.Background()) graceful.InitManager(managerCtx) diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 01f26d567f..27918a9ccc 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -80,7 +80,7 @@ func NewNilResponseHashSumRecorder() *NilResponseHashSumRecorder { } func TestMain(m *testing.M) { - defer log.Close() + defer log.GetManager().Close() managerCtx, cancel := context.WithCancel(context.Background()) graceful.InitManager(managerCtx) diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index a68d458a0b..556a54015b 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -24,7 +24,9 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/charset" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/testlogger" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/tests" @@ -35,6 +37,8 @@ import ( var currentEngine *xorm.Engine func initMigrationTest(t *testing.T) func() { + log.RegisterEventWriter("test", testlogger.NewTestLoggerWriter) + deferFn := tests.PrintCurrentTest(t, 2) giteaRoot := base.SetupGiteaRoot() if giteaRoot == "" { @@ -84,7 +88,7 @@ func initMigrationTest(t *testing.T) func() { assert.NoError(t, git.InitFull(context.Background())) setting.LoadDBSetting() - setting.InitLogs(true) + setting.InitLoggersForTest() return deferFn } @@ -292,7 +296,7 @@ func doMigrationTest(t *testing.T, version string) { return } - setting.InitSQLLog(false) + setting.InitSQLLoggersForCli(log.INFO) err := db.InitEngineWithMigration(context.Background(), wrappedMigrate) assert.NoError(t, err) diff --git a/tests/test_utils.go b/tests/test_utils.go index de022fde0a..6f0fb25560 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -36,6 +36,8 @@ func exitf(format string, args ...interface{}) { } func InitTest(requireGitea bool) { + log.RegisterEventWriter("test", testlogger.NewTestLoggerWriter) + giteaRoot := base.SetupGiteaRoot() if giteaRoot == "" { exitf("Environment variable $GITEA_ROOT not set") @@ -246,7 +248,3 @@ func PrintCurrentTest(t testing.TB, skip ...int) func() { func Printf(format string, args ...interface{}) { testlogger.Printf(format, args...) } - -func init() { - log.Register("test", testlogger.NewTestLogger) -} |