Skip to content

Commit

Permalink
fix: bootvolume unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiGuranIonos committed Jan 21, 2025
1 parent ab03627 commit 4b930b3
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions internal/controller/serverset/serverset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,10 +1090,10 @@ func Test_serverSetController_BootVolumeUpdate(t *testing.T) {
ConnectionDetails: managed.ConnectionDetails{},
},
wantCalls: map[ServiceMethodName]int{
serverGet: 2,
serverUpdate: 2,
bootVolumeEnsure: 2,
bootVolumeDelete: 2,
serverGet: 1,
serverUpdate: 1,
bootVolumeEnsure: 1,
bootVolumeDelete: 1,
bootVolumeGet: 2,
},
},
Expand All @@ -1119,10 +1119,10 @@ func Test_serverSetController_BootVolumeUpdate(t *testing.T) {
ConnectionDetails: managed.ConnectionDetails{},
},
wantCalls: map[ServiceMethodName]int{
serverGet: 2,
serverUpdate: 2,
bootVolumeEnsure: 2,
bootVolumeDelete: 2,
serverGet: 1,
serverUpdate: 1,
bootVolumeEnsure: 1,
bootVolumeDelete: 1,
bootVolumeGet: 2,
},
},
Expand All @@ -1148,15 +1148,15 @@ func Test_serverSetController_BootVolumeUpdate(t *testing.T) {
ConnectionDetails: managed.ConnectionDetails{},
},
wantCalls: map[ServiceMethodName]int{
serverEnsure: 2,
serverDelete: 2,
bootVolumeEnsure: 2,
bootVolumeDelete: 2,
nicEnsureNICs: 2,
nicDelete: 2,
bootVolumeGet: 2,
serverGet: 2,
serverUpdate: 2,
serverEnsure: 1,
serverDelete: 1,
bootVolumeEnsure: 1,
bootVolumeDelete: 1,
nicEnsureNICs: 1,
nicDelete: 1,
bootVolumeGet: 1,
serverGet: 1,
serverUpdate: 1,
},
},
{
Expand Down Expand Up @@ -1201,7 +1201,7 @@ func Test_serverSetController_BootVolumeUpdate(t *testing.T) {
Type: bootVolumeType,
}),
},
wantErr: fmt.Errorf("while updating volumes %w", fmt.Errorf("error updating server %w", errAnErrorWasReceived)),
wantErr: fmt.Errorf("while updating volumes for serverset serverset %w", fmt.Errorf("error updating volume %w", errAnErrorWasReceived)),
want: managed.ExternalUpdate{},
wantCalls: map[ServiceMethodName]int{
kubeUpdate: 1,
Expand All @@ -1224,10 +1224,11 @@ func Test_serverSetController_BootVolumeUpdate(t *testing.T) {
Type: "SSD",
}),
},
wantErr: fmt.Errorf("while updating volumes %w", errAnErrorWasReceived),
wantErr: fmt.Errorf("while updating volumes for serverset serverset %w", errAnErrorWasReceived),
want: managed.ExternalUpdate{},
wantCalls: map[ServiceMethodName]int{
bootVolumeEnsure: 1,
bootVolumeGet: 1,
},
},
}
Expand Down Expand Up @@ -1590,6 +1591,7 @@ func fakeBootVolumeCtrl() kubeBootVolumeControlManager {
func fakeBootVolumeCtrlEnsureMethodReturnsErr() kubeBootVolumeControlManager {
bootVolumeCtrl := new(kubeBootVolumeControlManagerFake)
bootVolumeCtrl.
On(getMethod, mock.Anything, mock.Anything, mock.Anything).Return(&v1alpha1.Volume{}, nil).
On(ensureMethod, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(errAnErrorWasReceived).
Times(1)
Expand Down

0 comments on commit 4b930b3

Please sign in to comment.