Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuker committed Aug 19, 2023
1 parent 805d71d commit ed9f197
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions pkg/runtime/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ func Test_NewObjectSyncer_CreateOrPatch_Patch(t *testing.T) {
},
}
sync, err := NewObjectSyncer(context.Background(), cli, nil, func() error {
patch.Data = map[string][]byte{
"after": []byte("after"),
if patch.Data == nil {
patch.Data = map[string][]byte{}
}
patch.Annotations = map[string]string{
"an3": "vn3",
patch.Data["after"] = []byte("after")
if patch.Annotations == nil {
patch.Annotations = map[string]string{}
}
patch.Annotations["an3"] = "vn3"
return nil
}, patch, SyncTypeCreateOrPatch).Sync(context.Background())
if err != nil {
Expand All @@ -67,11 +69,14 @@ func Test_NewObjectSyncer_CreateOrPatch_Patch(t *testing.T) {
t.Errorf("should make a update call")
}
if !reflect.DeepEqual(patch.Data, map[string][]byte{
"after": []byte("after"),
"after": []byte("after"),
"before": []byte("before"),
}) {
t.Errorf("patch failed")
}
if !reflect.DeepEqual(patch.Annotations, map[string]string{
"an1": "vn1",
"an2": "vn2",
"an3": "vn3",
}) {
t.Errorf("patch failed")
Expand Down Expand Up @@ -103,12 +108,14 @@ func Test_NewObjectSyncer_CreateOrUpdate_Update(t *testing.T) {
},
}
sync, err := NewObjectSyncer(context.Background(), cli, nil, func() error {
update.Data = map[string][]byte{
"after": []byte("after"),
if update.Data == nil {
update.Data = map[string][]byte{}
}
update.Annotations = map[string]string{
"an3": "vn3",
update.Data["after"] = []byte("after")
if update.Annotations == nil {
update.Annotations = map[string]string{}
}
update.Annotations["an3"] = "vn3"
return nil
}, update, SyncTypeCreateOrUpdate).Sync(context.Background())
if err != nil {
Expand All @@ -118,11 +125,14 @@ func Test_NewObjectSyncer_CreateOrUpdate_Update(t *testing.T) {
t.Errorf("should make a update call")
}
if !reflect.DeepEqual(update.Data, map[string][]byte{
"after": []byte("after"),
"after": []byte("after"),
"before": []byte("before"),
}) {
t.Errorf("update failed")
}
if !reflect.DeepEqual(update.Annotations, map[string]string{
"an1": "vn1",
"an2": "vn2",
"an3": "vn3",
}) {
t.Errorf("update failed")
Expand Down

0 comments on commit ed9f197

Please sign in to comment.