(t *testing.M)
| 72 | ) |
| 73 | |
| 74 | func TestMain(t *testing.M) { |
| 75 | dbSetting, ok := dbSettingMapping[os.Getenv("TEST_DB_DRIVER")] |
| 76 | if !ok { |
| 77 | // Use sqlite3 to test. |
| 78 | dbSetting = dbSettingMapping[string(schemas.SQLITE)] |
| 79 | } |
| 80 | if dbSetting.Driver == string(schemas.SQLITE) { |
| 81 | _ = os.RemoveAll(dbSetting.Connection) |
| 82 | } |
| 83 | |
| 84 | if err := initTestDataSource(dbSetting); err != nil { |
| 85 | panic(err) |
| 86 | } |
| 87 | log.Info("init test database successfully") |
| 88 | |
| 89 | ret := t.Run() |
| 90 | if tearDown != nil { |
| 91 | tearDown() |
| 92 | } |
| 93 | os.Exit(ret) |
| 94 | } |
| 95 | |
| 96 | type TestDBSetting struct { |
| 97 | Driver string |
nothing calls this directly
no test coverage detected