From 2fb45bdb309a42913a334fd391024e9ae681a7c9 Mon Sep 17 00:00:00 2001 From: Aniruddha Basak Date: Fri, 6 Oct 2023 11:09:30 +0530 Subject: [PATCH] Add test for azuremachine_webhook old subnetName is blank Signed-off-by: Aniruddha Basak --- api/v1beta1/azuremachine_webhook_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/v1beta1/azuremachine_webhook_test.go b/api/v1beta1/azuremachine_webhook_test.go index 460da487d47..25744a8df86 100644 --- a/api/v1beta1/azuremachine_webhook_test.go +++ b/api/v1beta1/azuremachine_webhook_test.go @@ -794,7 +794,22 @@ func TestAzureMachine_ValidateUpdate(t *testing.T) { }, wantErr: true, }, + { + name: "invalidtest: updating subnet name from empty to non empty", + oldMachine: &AzureMachine{ + Spec: AzureMachineSpec{ + NetworkInterfaces: []NetworkInterface{{SubnetName: ""}}, + }, + }, + newMachine: &AzureMachine{ + Spec: AzureMachineSpec{ + NetworkInterfaces: []NetworkInterface{{SubnetName: "subnet1"}}, + }, + }, + wantErr: true, + }, } + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { mw := &azureMachineWebhook{}