Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit ec48734

Browse files
committed
fix: simplify unit test matcher
1 parent ed4720c commit ec48734

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

pkg/handlers/nutanix/mutation/controlplaneendpoint/tests/generate_patches.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ package tests
66
import (
77
"testing"
88

9+
"github.com/onsi/gomega"
10+
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
11+
912
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
1013
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation"
1114
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
1215
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request"
13-
"github.com/onsi/gomega"
14-
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
1516
)
1617

1718
func TestGeneratePatches(
@@ -29,7 +30,7 @@ func TestGeneratePatches(
2930
Name: "unset variable",
3031
},
3132
capitest.PatchTestDef{
32-
Name: "ControlPlaneEndpoint set to valid host",
33+
Name: "ControlPlaneEndpoint set to valid host and port",
3334
Vars: []runtimehooksv1.Variable{
3435
capitest.VariableWithValue(
3536
variableName,
@@ -40,29 +41,13 @@ func TestGeneratePatches(
4041
variablePath...,
4142
),
4243
},
43-
RequestItem: request.NewNutanixClusterTemplateRequestItem("1"),
44+
RequestItem: request.NewNutanixClusterTemplateRequestItem(""),
4445
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{
4546
{
4647
Operation: "replace",
4748
Path: "/spec/template/spec/controlPlaneEndpoint/host",
4849
ValueMatcher: gomega.Equal("10.20.100.10"),
4950
},
50-
},
51-
},
52-
capitest.PatchTestDef{
53-
Name: "ControlPlaneEndpoint set to valid host",
54-
Vars: []runtimehooksv1.Variable{
55-
capitest.VariableWithValue(
56-
variableName,
57-
v1alpha1.NutanixControlPlaneEndpointSpec{
58-
Host: "10.20.100.10",
59-
Port: 6443,
60-
},
61-
variablePath...,
62-
),
63-
},
64-
RequestItem: request.NewNutanixClusterTemplateRequestItem("2"),
65-
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{
6651
{
6752
Operation: "replace",
6853
Path: "/spec/template/spec/controlPlaneEndpoint/port",

0 commit comments

Comments
 (0)