mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
Add UT for webhook when replicating with docker registry
Signed-off-by: guanxiatao <guanxiatao@corp.netease.com>
This commit is contained in:
parent
bcbab31fe1
commit
0aefd8f2e2
@ -92,7 +92,15 @@ func (f *fakedReplicationMgr) GetExecution(int64) (*daoModels.Execution, error)
|
||||
func (f *fakedReplicationMgr) ListTasks(...*daoModels.TaskQuery) (int64, []*daoModels.Task, error) {
|
||||
return 0, nil, nil
|
||||
}
|
||||
func (f *fakedReplicationMgr) GetTask(int64) (*daoModels.Task, error) {
|
||||
func (f *fakedReplicationMgr) GetTask(id int64) (*daoModels.Task, error) {
|
||||
if id == 1 {
|
||||
return &daoModels.Task{
|
||||
ExecutionID: 1,
|
||||
// project info not included when replicating with docker registry
|
||||
SrcResource: "alpine:[v1]",
|
||||
DstResource: "gxt/alpine:[v1] ",
|
||||
}, nil
|
||||
}
|
||||
return &daoModels.Task{
|
||||
ExecutionID: 1,
|
||||
SrcResource: "library/alpine:[v1]",
|
||||
@ -254,14 +262,14 @@ func TestReplicationHandler_Handle(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "ImagePreprocessHandler Want Error 1",
|
||||
name: "ReplicationHandler Want Error 1",
|
||||
args: args{
|
||||
data: "",
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "ImagePreprocessHandler 1",
|
||||
name: "ReplicationHandler 1",
|
||||
args: args{
|
||||
data: &event.ReplicationEvent{
|
||||
OccurAt: time.Now(),
|
||||
@ -269,6 +277,16 @@ func TestReplicationHandler_Handle(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "ReplicationHandler with docker registry",
|
||||
args: args{
|
||||
data: &event.ReplicationEvent{
|
||||
OccurAt: time.Now(),
|
||||
ReplicationTaskID: 1,
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user