Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ekarlso committed Oct 9, 2024
1 parent bee82b0 commit f618472
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/service/vmservice/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func checkCloudInitStatus(ctx context.Context, machineScope *scope.MachineScope)
}
}

if !machineScope.SkipQemuGuestCheck() && !machineScope.SkipCloudInitCheck() {
if !machineScope.SkipCloudInitCheck() {
if running, err := machineScope.InfraCluster.ProxmoxClient.CloudInitStatus(ctx, machineScope.VirtualMachine); err != nil || running {
if running {
return true, nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ func (m *MachineScope) SkipQemuGuestCheck() bool {

// SkipCloudInitCheck check whether cloud-init status check is enabled.
func (m *MachineScope) SkipCloudInitCheck() bool {
if m.SkipQemuGuestCheck() {
return false
}

if m.ProxmoxMachine.Spec.Checks != nil {
return ptr.Deref(m.ProxmoxMachine.Spec.Checks.SkipCloudInitStatus, false)
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/scope/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ func TestMachineScope_SkipCloudInit(t *testing.T) {
require.False(t, scope.SkipQemuGuestCheck())
}

func TestMachineScope_SkipQemuDisablesCloudInitCheck(t *testing.T) {
p := infrav1alpha1.ProxmoxMachine{
Spec: infrav1alpha1.ProxmoxMachineSpec{
Checks: &infrav1alpha1.ProxmoxMachineChecks{
SkipQemuGuestAgent: ptr.To(true),
},
},
}
scope := MachineScope{
ProxmoxMachine: &p,
}

require.False(t, scope.SkipCloudInitCheck())
}

func TestMachineScope_GetBootstrapSecret(t *testing.T) {
client := fake.NewClientBuilder().Build()
p := infrav1alpha1.ProxmoxMachine{
Expand Down

0 comments on commit f618472

Please sign in to comment.