aboutsummaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-12-06 01:06:24 +0800
committerGitHub <noreply@github.com>2020-12-06 01:06:24 +0800
commit72af17bbbe0b324d3b951819b0755134f0c214ec (patch)
treea0a94221c818bf3477bfc516b9c4d7ed22398bc8 /internal/db
parentc875950c438b1ccbb546fecb4905680a0cbd38a7 (diff)
db: simplify GORM logger init in tests (#6444)
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/main_test.go12
1 files changed, 1 insertions, 11 deletions
diff --git a/internal/db/main_test.go b/internal/db/main_test.go
index 09f175c5..9491bda9 100644
--- a/internal/db/main_test.go
+++ b/internal/db/main_test.go
@@ -7,8 +7,6 @@ package db
import (
"flag"
"fmt"
- "io/ioutil"
- stdlog "log"
"os"
"path/filepath"
"testing"
@@ -20,14 +18,12 @@ import (
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/conf"
- "gogs.io/gogs/internal/dbutil"
"gogs.io/gogs/internal/testutil"
)
func TestMain(m *testing.M) {
flag.Parse()
- var w logger.Writer
level := logger.Silent
if !testing.Verbose() {
// Remove the primary logger and register a noop logger.
@@ -37,18 +33,12 @@ func TestMain(m *testing.M) {
fmt.Println(err)
os.Exit(1)
}
-
- w = &dbutil.Logger{Writer: ioutil.Discard}
} else {
- w = stdlog.New(os.Stdout, "\r\n", stdlog.LstdFlags)
level = logger.Info
}
// NOTE: AutoMigrate does not respect logger passed in gorm.Config.
- logger.Default = logger.New(w, logger.Config{
- SlowThreshold: 100 * time.Millisecond,
- LogLevel: level,
- })
+ logger.Default = logger.Default.LogMode(level)
os.Exit(m.Run())
}