diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-11 05:39:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 05:39:45 +0800 |
commit | 76bb647d2437dbdea86ac1a0caf5d768ab924e18 (patch) | |
tree | 94a59406f014521d17e662ba4dcf2545b6d3a5ff /internal/db/main_test.go | |
parent | e077ecdd9d95ecb76d91105b3858ee48d52c0cc2 (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.go | 5 |
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 { |