mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-12 02:41:50 +01:00
Merge pull request #8168 from ywk253100/190626_dao_test
Clean up the dao test for replication
This commit is contained in:
commit
b9c96f7e56
@ -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())
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user