From aefd581bf254fc3fc7e6789e99a3042b61aebc0d Mon Sep 17 00:00:00 2001 From: shysank Date: Thu, 21 Oct 2021 12:54:25 -0700 Subject: [PATCH] add test for default mismatch --- api/v1beta1/azurecluster_webhook_test.go | 10 +++++ .../azuremachinetemplate_webhook_test.go | 43 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/api/v1beta1/azurecluster_webhook_test.go b/api/v1beta1/azurecluster_webhook_test.go index d95a153688e..3014825043f 100644 --- a/api/v1beta1/azurecluster_webhook_test.go +++ b/api/v1beta1/azurecluster_webhook_test.go @@ -234,6 +234,16 @@ func TestAzureCluster_ValidateUpdate(t *testing.T) { }, wantErr: true, }, + { + name: "azurecluster azureEnvironment default mismatch", + oldCluster: createValidCluster(), + cluster: func() *AzureCluster { + cluster := createValidCluster() + cluster.Spec.AzureEnvironment = "AzurePublicCloud" + return cluster + }(), + wantErr: false, + }, { name: "control plane outbound lb is immutable", oldCluster: &AzureCluster{ diff --git a/api/v1beta1/azuremachinetemplate_webhook_test.go b/api/v1beta1/azuremachinetemplate_webhook_test.go index d9240dc462d..596929ed498 100644 --- a/api/v1beta1/azuremachinetemplate_webhook_test.go +++ b/api/v1beta1/azuremachinetemplate_webhook_test.go @@ -226,6 +226,49 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { }, wantErr: false, }, + { + name: "AzureMachineTemplate with default mismatch", + oldTemplate: &AzureMachineTemplate{ + Spec: AzureMachineTemplateSpec{ + Template: AzureMachineTemplateResource{ + Spec: AzureMachineSpec{ + VMSize: "size", + FailureDomain: &failureDomain, + OSDisk: OSDisk{ + OSType: "type", + DiskSizeGB: to.Int32Ptr(11), + CachingType: "", + }, + DataDisks: []DataDisk{}, + SSHPublicKey: "", + }, + }, + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "OldTemplate", + }, + }, + template: &AzureMachineTemplate{ + Spec: AzureMachineTemplateSpec{ + Template: AzureMachineTemplateResource{ + Spec: AzureMachineSpec{ + VMSize: "size", + FailureDomain: &failureDomain, + OSDisk: OSDisk{ + OSType: "type", + DiskSizeGB: to.Int32Ptr(11), + CachingType: "None", + }, + DataDisks: []DataDisk{}, + }, + }, + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "NewTemplate", + }, + }, + wantErr: false, + }, } for _, amt := range tests {