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

Function fakeScaleClient

scale/client_test.go:55–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func fakeScaleClient(t *testing.T) (ScalesGetter, []schema.GroupResource) {
56 fakeDiscoveryClient := &fakedisco.FakeDiscovery{Fake: &coretesting.Fake{}}
57 fakeDiscoveryClient.Resources = []*metav1.APIResourceList{
58 {
59 GroupVersion: corev1.SchemeGroupVersion.String(),
60 APIResources: []metav1.APIResource{
61 {Name: "pods", Namespaced: true, Kind: "Pod"},
62 {Name: "replicationcontrollers", Namespaced: true, Kind: "ReplicationController"},
63 {Name: "replicationcontrollers/scale", Namespaced: true, Kind: "Scale", Group: "autoscaling", Version: "v1"},
64 },
65 },
66 {
67 GroupVersion: extv1beta1.SchemeGroupVersion.String(),
68 APIResources: []metav1.APIResource{
69 {Name: "replicasets", Namespaced: true, Kind: "ReplicaSet"},
70 {Name: "replicasets/scale", Namespaced: true, Kind: "Scale"},
71 },
72 },
73 {
74 GroupVersion: appsv1beta2.SchemeGroupVersion.String(),
75 APIResources: []metav1.APIResource{
76 {Name: "deployments", Namespaced: true, Kind: "Deployment"},
77 {Name: "deployments/scale", Namespaced: true, Kind: "Scale", Group: "apps", Version: "v1beta2"},
78 },
79 },
80 {
81 GroupVersion: appsv1beta1.SchemeGroupVersion.String(),
82 APIResources: []metav1.APIResource{
83 {Name: "statefulsets", Namespaced: true, Kind: "StatefulSet"},
84 {Name: "statefulsets/scale", Namespaced: true, Kind: "Scale", Group: "apps", Version: "v1beta1"},
85 },
86 },
87 // test a resource that doesn't exist anywere to make sure we're not accidentally depending
88 // on a static RESTMapper anywhere.
89 {
90 GroupVersion: "cheese.testing.k8s.io/v27alpha15",
91 APIResources: []metav1.APIResource{
92 {Name: "cheddars", Namespaced: true, Kind: "Cheddar"},
93 {Name: "cheddars/scale", Namespaced: true, Kind: "Scale", Group: "extensions", Version: "v1beta1"},
94 },
95 },
96 }
97
98 restMapperRes, err := restmapper.GetAPIGroupResources(fakeDiscoveryClient)
99 if err != nil {
100 t.Fatalf("unexpected error while constructing resource list from fake discovery client: %v", err)
101 }
102 restMapper := restmapper.NewDiscoveryRESTMapper(restMapperRes)
103
104 autoscalingScale := &autoscalingv1.Scale{
105 TypeMeta: metav1.TypeMeta{
106 Kind: "Scale",
107 APIVersion: autoscalingv1.SchemeGroupVersion.String(),
108 },
109 ObjectMeta: metav1.ObjectMeta{
110 Name: "foo",
111 },
112 Spec: autoscalingv1.ScaleSpec{Replicas: 10},

Callers 2

TestGetScaleFunction · 0.85
TestUpdateScaleFunction · 0.85

Calls 11

GetAPIGroupResourcesFunction · 0.92
NewDiscoveryRESTMapperFunction · 0.92
defaultHeadersFunction · 0.85
bytesBodyFunction · 0.85
NewFunction · 0.70
StringMethod · 0.65
ErrorfMethod · 0.65
DecodeMethod · 0.45
GroupVersionKindMethod · 0.45
GetObjectKindMethod · 0.45

Tested by

no test coverage detected