aboutsummaryrefslogtreecommitdiff
path: root/internal/db/main_test.go
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-04-11 05:39:45 +0800
committerGitHub <noreply@github.com>2020-04-11 05:39:45 +0800
commit76bb647d2437dbdea86ac1a0caf5d768ab924e18 (patch)
tree94a59406f014521d17e662ba4dcf2545b6d3a5ff /internal/db/main_test.go
parente077ecdd9d95ecb76d91105b3858ee48d52c0cc2 (diff)
db: add tests for permissions (#6088)
* Add flag to print SQLs * Add tests for perms * Make results stable * codecov: only show diff * Once again, stable find results
Diffstat (limited to 'internal/db/main_test.go')
-rw-r--r--internal/db/main_test.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/db/main_test.go b/internal/db/main_test.go
index 8b4190da..fdd7447f 100644
--- a/internal/db/main_test.go
+++ b/internal/db/main_test.go
@@ -21,6 +21,8 @@ import (
"gogs.io/gogs/internal/testutil"
)
+var printSQL = flag.Bool("print-sql", false, "Print SQL executed")
+
func TestMain(m *testing.M) {
flag.Parse()
if !testing.Verbose() {
@@ -75,6 +77,9 @@ func initTestDB(t *testing.T, suite string, tables ...interface{}) *gorm.DB {
if !testing.Verbose() {
db.SetLogger(&dbutil.Writer{Writer: ioutil.Discard})
}
+ if *printSQL {
+ db.LogMode(true)
+ }
err = db.AutoMigrate(tables...).Error
if err != nil {