Skip to content

Commit

Permalink
add validateUpdate test
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Dec 21, 2022
1 parent 4a85051 commit 56d0cf0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions api/v1beta1/azuremachine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,48 @@ func TestAzureMachine_ValidateUpdate(t *testing.T) {
},
wantErr: false,
},
{
name: "validTest: azuremachine.spec.Diagnostics should not error on updating nil diagnostics",
oldMachine: &AzureMachine{
Spec: AzureMachineSpec{},
},
newMachine: &AzureMachine{
Spec: AzureMachineSpec{
Diagnostics: &Diagnostics{Boot: &BootDiagnostics{StorageAccountType: ManagedDiagnosticsStorage}},
},
},
wantErr: false,
},
{
name: "invalidTest: azuremachine.spec.Diagnostics is immutable",
oldMachine: &AzureMachine{
Spec: AzureMachineSpec{
Diagnostics: &Diagnostics{},
},
},
newMachine: &AzureMachine{
Spec: AzureMachineSpec{
Diagnostics: &Diagnostics{Boot: &BootDiagnostics{StorageAccountType: ManagedDiagnosticsStorage}},
},
},
wantErr: true,
},
{
name: "invalidTest: azuremachine.spec.Diagnostics is immutable",
oldMachine: &AzureMachine{
Spec: AzureMachineSpec{
Diagnostics: &Diagnostics{
Boot: &BootDiagnostics{},
},
},
},
newMachine: &AzureMachine{
Spec: AzureMachineSpec{
Diagnostics: &Diagnostics{Boot: &BootDiagnostics{StorageAccountType: ManagedDiagnosticsStorage}},
},
},
wantErr: true,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 56d0cf0

Please sign in to comment.