mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #52461 from stewart-yu/issue#05
Automatic merge from submit-queue (batch tested with PRs 52461, 55503). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add testcase for SelfLink function **What this PR does / why we need it**: Add testcase for SelfLink function. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
589b1b107d
@ -74,6 +74,36 @@ var status = &metav1.Status{
|
|||||||
Message: "",
|
Message: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSelfLink(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
resource string
|
||||||
|
name string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"resource", "name", "/api/" + Default.GroupVersion().Version + "/resource/name"},
|
||||||
|
{"resource", "", "/api/" + Default.GroupVersion().Version + "/resource"},
|
||||||
|
}
|
||||||
|
for _, item := range testCases {
|
||||||
|
if actual := Default.SelfLink(item.resource, item.name); actual != item.expected {
|
||||||
|
t.Errorf("Expected: %s, got: %s for resource: %s and name: %s", item.expected, actual, item.resource, item.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testGroupCases := []struct {
|
||||||
|
resource string
|
||||||
|
name string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"resource", "name", "/apis/" + Admission.GroupVersion().Group + "/" + Admission.GroupVersion().Version + "/resource/name"},
|
||||||
|
{"resource", "", "/apis/" + Admission.GroupVersion().Group + "/" + Admission.GroupVersion().Version + "/resource"},
|
||||||
|
}
|
||||||
|
for _, item := range testGroupCases {
|
||||||
|
if actual := Admission.SelfLink(item.resource, item.name); actual != item.expected {
|
||||||
|
t.Errorf("Expected: %s, got: %s for resource: %s and name: %s", item.expected, actual, item.resource, item.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestV1EncodeDecodeStatus(t *testing.T) {
|
func TestV1EncodeDecodeStatus(t *testing.T) {
|
||||||
v1Codec := Default.Codec()
|
v1Codec := Default.Codec()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user