From 5990a2376e2ef2737ae79e6b92b218cdf6b23c7f Mon Sep 17 00:00:00 2001 From: majimenez-stratio Date: Fri, 30 Sep 2022 15:39:59 +0200 Subject: [PATCH] Add unit test --- api/v1beta1/azuremachine_webhook_test.go | 11 +++++++++++ api/v1beta1/azuremachinetemplate_webhook_test.go | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/api/v1beta1/azuremachine_webhook_test.go b/api/v1beta1/azuremachine_webhook_test.go index 75a5815f212c..d12f4271a373 100644 --- a/api/v1beta1/azuremachine_webhook_test.go +++ b/api/v1beta1/azuremachine_webhook_test.go @@ -627,3 +627,14 @@ func createMachineWithRoleAssignmentName() *AzureMachine { } return machine } + +func createMachineWithoutRoleAssignmentName() *AzureMachine { + machine := &AzureMachine{ + Spec: AzureMachineSpec{ + SSHPublicKey: validSSHPublicKey, + OSDisk: validOSDisk, + Identity: VMIdentitySystemAssigned, + }, + } + return machine +} diff --git a/api/v1beta1/azuremachinetemplate_webhook_test.go b/api/v1beta1/azuremachinetemplate_webhook_test.go index ff2d45346ce2..4bc4d5a9cda8 100644 --- a/api/v1beta1/azuremachinetemplate_webhook_test.go +++ b/api/v1beta1/azuremachinetemplate_webhook_test.go @@ -133,6 +133,11 @@ func TestAzureMachineTemplate_ValidateCreate(t *testing.T) { machineTemplate: createAzureMachineTemplateFromMachine(createMachineWithRoleAssignmentName()), wantErr: true, }, + { + name: "azuremachinetemplate without RoleAssignmentName", + machineTemplate: createAzureMachineTemplateFromMachine(createMachineWithoutRoleAssignmentName()), + wantErr: false, + }, } for _, test := range tests {