mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-04 22:11:40 +01:00
pass go test
This commit is contained in:
parent
0f557d54ef
commit
51627d4d40
@ -1139,24 +1139,40 @@ func TestGetRepPolicyByProject(t *testing.T) {
|
|||||||
func TestGetRepJobByPolicy(t *testing.T) {
|
func TestGetRepJobByPolicy(t *testing.T) {
|
||||||
jobs, err := GetRepJobByPolicy(999)
|
jobs, err := GetRepJobByPolicy(999)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error occured in GetRepJobByPolicy: %v, policy ID: %d", err, 999)
|
t.Errorf("Error occured in GetRepJobByPolicy: %v, policy ID: %d", err, 999)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(jobs) > 0 {
|
if len(jobs) > 0 {
|
||||||
log.Errorf("Unexpected length of jobs, expected: 0, in fact: %d", len(jobs))
|
t.Errorf("Unexpected length of jobs, expected: 0, in fact: %d", len(jobs))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jobs, err = GetRepJobByPolicy(policyID)
|
jobs, err = GetRepJobByPolicy(policyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error occured in GetRepJobByPolicy: %v, policy ID: %d", err, policyID)
|
t.Errorf("Error occured in GetRepJobByPolicy: %v, policy ID: %d", err, policyID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(jobs) != 1 {
|
if len(jobs) != 1 {
|
||||||
log.Errorf("Unexpected length of jobs, expected: 1, in fact: %d", len(jobs))
|
t.Errorf("Unexpected length of jobs, expected: 1, in fact: %d", len(jobs))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if jobs[0].ID != jobID {
|
if jobs[0].ID != jobID {
|
||||||
log.Errorf("Unexpected job ID in the result, expected: %d, in fact: %d", jobID, jobs[0].ID)
|
t.Errorf("Unexpected job ID in the result, expected: %d, in fact: %d", jobID, jobs[0].ID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterRepJobs(t *testing.T) {
|
||||||
|
jobs, err := FilterRepJobs(policyID, "", "", nil, nil, 1000)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error occured in FilterRepJobs: %v, policy ID: %d", err, policyID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(jobs) != 1 {
|
||||||
|
t.Errorf("Unexpected length of jobs, expected: 1, in fact: %d", len(jobs))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if jobs[0].ID != jobID {
|
||||||
|
t.Errorf("Unexpected job ID in the result, expected: %d, in fact: %d", jobID, jobs[0].ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1179,22 +1195,6 @@ func TestDeleteRepJob(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterRepJobs(t *testing.T) {
|
|
||||||
jobs, err := FilterRepJobs(policyID, "", "", nil, nil, 1000)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("Error occured in FilterRepJobs: %v, policy ID: %d", err, policyID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(jobs) != 1 {
|
|
||||||
log.Errorf("Unexpected length of jobs, expected: 1, in fact: %d", len(jobs))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if jobs[0].ID != jobID {
|
|
||||||
log.Errorf("Unexpected job ID in the result, expected: %d, in fact: %d", jobID, jobs[0].ID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetRepoJobToStop(t *testing.T) {
|
func TestGetRepoJobToStop(t *testing.T) {
|
||||||
jobs := [...]models.RepJob{
|
jobs := [...]models.RepJob{
|
||||||
models.RepJob{
|
models.RepJob{
|
||||||
@ -1265,7 +1265,7 @@ func TestDeleteRepTarget(t *testing.T) {
|
|||||||
func TestFilterRepPolicies(t *testing.T) {
|
func TestFilterRepPolicies(t *testing.T) {
|
||||||
_, err := FilterRepPolicies("name", 0)
|
_, err := FilterRepPolicies("name", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to filter policy")
|
t.Fatalf("failed to filter policy: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ func FilterRepPolicies(name string, projectID int64) ([]*models.RepPolicy, error
|
|||||||
left join project p on rp.project_id=p.project_id
|
left join project p on rp.project_id=p.project_id
|
||||||
left join replication_target rt on rp.target_id=rt.id
|
left join replication_target rt on rp.target_id=rt.id
|
||||||
left join replication_job rj on rp.id=rj.policy_id and (rj.status="error"
|
left join replication_job rj on rp.id=rj.policy_id and (rj.status="error"
|
||||||
or rj.status="retrying") group by rp.id `
|
or rj.status="retrying") `
|
||||||
|
|
||||||
if len(name) != 0 && projectID != 0 {
|
if len(name) != 0 && projectID != 0 {
|
||||||
sql += `where rp.name like ? and rp.project_id = ? `
|
sql += `where rp.name like ? and rp.project_id = ? `
|
||||||
@ -170,7 +170,7 @@ func FilterRepPolicies(name string, projectID int64) ([]*models.RepPolicy, error
|
|||||||
args = append(args, projectID)
|
args = append(args, projectID)
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += `order by rp.creation_time`
|
sql += `group by rp.id order by rp.creation_time`
|
||||||
|
|
||||||
var policies []*models.RepPolicy
|
var policies []*models.RepPolicy
|
||||||
if _, err := o.Raw(sql, args).QueryRows(&policies); err != nil {
|
if _, err := o.Raw(sql, args).QueryRows(&policies); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user