Skip to content

Commit

Permalink
test: address test feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis committed May 4, 2020
1 parent 71ee8d7 commit bae65c5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions api/v1alpha3/azurecluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"testing"

. "github.com/onsi/gomega"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/validation/field"
)

func TestAzureCluster_ValidateUpdate(t *testing.T) {
Expand All @@ -29,27 +31,32 @@ func TestAzureCluster_ValidateUpdate(t *testing.T) {
name string
cluster *AzureCluster
updated *AzureCluster
wantErr bool
err error
}{
{
name: "no change",
cluster: createAzureCluster(t, "westus2"),
updated: createAzureCluster(t, "westus2"),
wantErr: false,
err: nil,
},
{
name: "no change",
name: "update location should throw an error",
cluster: createAzureCluster(t, "westus2"),
updated: createAzureCluster(t, "eastus"),
wantErr: true,
err: apierrors.NewInvalid(
GroupVersion.WithKind("AzureCluster").GroupKind(),
"westus2", field.ErrorList{
field.Invalid(field.NewPath("location"), "westus2", "AzureCluster Location is not mutable"),
}),
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := tc.cluster.ValidateUpdate(tc.updated)
if tc.wantErr {
if tc.err != nil {
g.Expect(err).To(HaveOccurred())
g.Expect(err).To(Equal(tc.err))
} else {
g.Expect(err).NotTo(HaveOccurred())
}
Expand Down

0 comments on commit bae65c5

Please sign in to comment.