Decouple unit test code from business code (#17623)

This commit is contained in:
wxiaoguang 2021-11-12 22:36:47 +08:00 committed by GitHub
parent 7f802631c5
commit df64fa4865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
136 changed files with 1058 additions and 830 deletions

View file

@ -124,7 +124,8 @@ func NewEngine() (*xorm.Engine, error) {
return engine, nil
}
func syncTables() error {
//SyncAllTables sync the schemas of all tables, is required by unit test code
func SyncAllTables() error {
return x.StoreEngine("InnoDB").Sync2(tables...)
}
@ -176,7 +177,7 @@ func InitEngineWithMigration(ctx context.Context, migrateFunc func(*xorm.Engine)
return fmt.Errorf("migrate: %v", err)
}
if err = syncTables(); err != nil {
if err = SyncAllTables(); err != nil {
return fmt.Errorf("sync database struct error: %v", err)
}