Merge pull request #8168 from ywk253100/190626_dao_test

Clean up the dao test for replication
This commit is contained in:
Daniel Jiang 2019-07-01 15:05:51 +08:00 committed by GitHub
commit b9c96f7e56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 35 deletions

View File

@ -21,22 +21,7 @@ import (
"github.com/goharbor/harbor/src/common/dao"
)
// TODO clean up the file
func TestMain(m *testing.M) {
dao.PrepareTestForPostgresSQL()
var code = m.Run()
// clear test database
var clearSqls = []string{
`DROP TABLE "access", "access_log", "admin_job", "alembic_version", "clair_vuln_timestamp",
"harbor_label", "harbor_resource_label", "harbor_user", "img_scan_job", "img_scan_overview",
"job_log", "project", "project_member", "project_metadata", "properties", "registry",
"replication_policy", "repository", "robot", "role", "schema_migrations", "user_group",
"replication_execution", "replication_task", "replication_schedule_job", "oidc_user", "cve_whitelist";`,
`DROP FUNCTION "update_update_time_at_column"();`,
}
dao.PrepareTestData(clearSqls, nil)
os.Exit(code)
os.Exit(m.Run())
}

View File

@ -6,7 +6,6 @@ import (
"time"
"github.com/goharbor/harbor/src/common/dao"
"github.com/goharbor/harbor/src/common/utils/log"
"github.com/goharbor/harbor/src/replication/dao/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -15,24 +14,8 @@ import (
var executionManager = NewDefaultManager()
func TestMain(m *testing.M) {
databases := []string{"postgresql"}
for _, database := range databases {
log.Infof("run test cases for database: %s", database)
result := 1
switch database {
case "postgresql":
dao.PrepareTestForPostgresSQL()
default:
log.Fatalf("invalid database: %s", database)
}
result = m.Run()
if result != 0 {
os.Exit(result)
}
}
dao.PrepareTestForPostgresSQL()
os.Exit(m.Run())
}
func TestMethodOfExecutionManager(t *testing.T) {