Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
majimenez-stratio committed Sep 30, 2022
1 parent e022e4c commit 5990a23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/v1beta1/azuremachine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,3 +627,14 @@ func createMachineWithRoleAssignmentName() *AzureMachine {
}
return machine
}

func createMachineWithoutRoleAssignmentName() *AzureMachine {
machine := &AzureMachine{
Spec: AzureMachineSpec{
SSHPublicKey: validSSHPublicKey,
OSDisk: validOSDisk,
Identity: VMIdentitySystemAssigned,
},
}
return machine
}
5 changes: 5 additions & 0 deletions api/v1beta1/azuremachinetemplate_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5990a23

Please sign in to comment.