Skip to content

Commit c77135f

Browse files
committed
Fix unit tests
1 parent 982ed7f commit c77135f

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

pkg/gather/clusterconfig/container_runtime_configs_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ metadata:
2020
name: test-ContainerRC
2121
`
2222
gvr := schema.GroupVersionResource{Group: "machineconfiguration.openshift.io", Version: "v1", Resource: "containerruntimeconfigs"}
23-
client := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
23+
client := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), map[schema.GroupVersionResource]string{
24+
gvr: "ContainerRuntimeConfigsList",
25+
})
2426
decUnstructured := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme)
2527

2628
testContainerRuntimeConfigs := &unstructured.Unstructured{}

pkg/gather/clusterconfig/install_plans_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestGatherInstallPlans(t *testing.T) {
5252
for _, test := range tests {
5353
t.Run(test.name, func(t *testing.T) {
5454

55-
client := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
55+
var client *dynamicfake.FakeDynamicClient
5656
coreClient := kubefake.NewSimpleClientset()
5757
for _, file := range test.testfiles {
5858
f, err := os.Open(file)
@@ -86,6 +86,11 @@ func TestGatherInstallPlans(t *testing.T) {
8686
if err != nil {
8787
t.Fatal("unable to create ns fake ", err)
8888
}
89+
if client == nil {
90+
client = dynamicfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), map[schema.GroupVersionResource]string{
91+
gvr: "InstallPlansList",
92+
})
93+
}
8994
_, err = client.Resource(gvr).Namespace(ns).Create(context.Background(), installplan, metav1.CreateOptions{})
9095
if err != nil {
9196
t.Fatal("unable to create installplan fake ", err)

pkg/gather/clusterconfig/machine_config_pools_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ metadata:
2020
name: master-t
2121
`
2222
gvr := schema.GroupVersionResource{Group: "machineconfiguration.openshift.io", Version: "v1", Resource: "machineconfigpools"}
23-
client := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
23+
client := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), map[schema.GroupVersionResource]string{
24+
gvr: "MachineConfigPoolsList",
25+
})
2426
decUnstructured := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme)
2527

2628
testMachineConfigPools := &unstructured.Unstructured{}

pkg/gather/clusterconfig/machine_sets_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ metadata:
2020
name: test-worker
2121
`
2222
gvr := schema.GroupVersionResource{Group: "machine.openshift.io", Version: "v1beta1", Resource: "machinesets"}
23-
client := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
23+
client := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(runtime.NewScheme(), map[schema.GroupVersionResource]string{
24+
gvr: "MachineSetsList",
25+
})
2426
decUnstructured := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme)
2527

2628
testMachineSet := &unstructured.Unstructured{}

0 commit comments

Comments
 (0)