MCPcopy
hub / github.com/kubernetes/client-go / TestGetReferenceRefVersion

Function TestGetReferenceRefVersion

tools/reference/ref_test.go:36–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestGetReferenceRefVersion(t *testing.T) {
37 tests := []struct {
38 name string
39 input *TestRuntimeObj
40 expectedRefVersion string
41 }{
42 {
43 name: "api from selflink",
44 input: &TestRuntimeObj{
45 ObjectMeta: metav1.ObjectMeta{SelfLink: "/api/v1/namespaces"},
46 },
47 expectedRefVersion: "v1",
48 },
49 {
50 name: "foo.group/v3 from selflink",
51 input: &TestRuntimeObj{
52 ObjectMeta: metav1.ObjectMeta{SelfLink: "/apis/foo.group/v3/namespaces"},
53 },
54 expectedRefVersion: "foo.group/v3",
55 },
56 }
57
58 scheme := runtime.NewScheme()
59 scheme.AddKnownTypes(schema.GroupVersion{Group: "this", Version: "is ignored"}, &TestRuntimeObj{})
60
61 for _, test := range tests {
62 t.Run(test.name, func(t *testing.T) {
63 ref, err := GetReference(scheme, test.input)
64 if err != nil {
65 t.Fatal(err)
66 }
67 if test.expectedRefVersion != ref.APIVersion {
68 t.Errorf("expected %q, got %q", test.expectedRefVersion, ref.APIVersion)
69 }
70 })
71 }
72}

Callers

nothing calls this directly

Calls 3

GetReferenceFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected