Created
May 4, 2023 16:51
-
-
Save stevenctl/d064c8afd04e8246c2b54fa008281b6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package crdclient | |
func TestGenMergePatch(t *testing.T) { | |
existing := &clientnetworkingv1alpha3.WorkloadEntry{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: "foo-we", | |
Namespace: "ns", | |
Labels: map[string]string{ | |
"oldlabel": "oldvalue", | |
}, | |
UID: "12345678", | |
ResourceVersion: "1", | |
}, | |
Spec: v1alpha3.WorkloadEntry{ | |
Labels: map[string]string{ | |
"oldlabel": "oldvalue", | |
}, | |
}, | |
} | |
modified := &clientnetworkingv1alpha3.WorkloadEntry{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: "foo-we", | |
Namespace: "ns", | |
Labels: map[string]string{ | |
"newlabel": "newvalue", | |
}, | |
UID: "12345678", | |
ResourceVersion: "1", | |
}, | |
Spec: v1alpha3.WorkloadEntry{ | |
Labels: map[string]string{ | |
"newlabel": "newvalue", | |
}, | |
}, | |
} | |
bytes, _ := genPatchBytes(existing, modified, types.MergePatchType) | |
fmt.Println(string(bytes)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment