diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-04-18 12:07:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-18 12:07:30 +0800 |
commit | 9d64d222a8c30db5076a591981ad7cfe672ba6f1 (patch) | |
tree | c753eb898a1ead0afbe5b6a7a28b466ab0d2b8ac /internal/db/main_test.go | |
parent | fa497b16332c24bc4d9e788c64bda94e3c1499a7 (diff) |
db: add tests for users (#6116)
* Add new methods
* Use Users.Create to replace previous hack
* Reduce side effect
* Do not clear tables when test failed
* test_users_Authenticate
* Rename constant
* test_users_Create
* test_users_GetByEmail
* test_users_GetByID
* test_users_GetByUsername
Diffstat (limited to 'internal/db/main_test.go')
-rw-r--r-- | internal/db/main_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/db/main_test.go b/internal/db/main_test.go index 172f00fe..c6cc6f9e 100644 --- a/internal/db/main_test.go +++ b/internal/db/main_test.go @@ -42,7 +42,11 @@ func TestMain(m *testing.M) { } // clearTables removes all rows from given tables. -func clearTables(db *gorm.DB, tables ...interface{}) error { +func clearTables(t *testing.T, db *gorm.DB, tables ...interface{}) error { + if t.Failed() { + return nil + } + for _, t := range tables { err := db.Delete(t).Error if err != nil { |