Skip to content

Commit

Permalink
[issue-1198] adding tests
Browse files Browse the repository at this point in the history
Signed-off-by: katarzynakulpa <[email protected]>
  • Loading branch information
katarzynakulpa committed Jul 10, 2024
1 parent 1581f39 commit 74f93d2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/crcontrollers/drive/drivecontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,33 @@ func TestDriveController_handleDriveStatus(t *testing.T) {
assert.NotNil(t, resultVolume[0].Spec)
assert.Equal(t, resultVolume[0].Spec.OperationalStatus, apiV1.OperationalStatusOperative)

assert.Nil(t, dc.client.DeleteCR(testCtx, expectedD))
assert.Nil(t, dc.client.DeleteCR(testCtx, expectedV))
})
t.Run("Missing volume status for fake attach", func(t *testing.T) {
expectedD := testBadCRDrive.DeepCopy()
assert.NotNil(t, expectedD)
assert.Nil(t, dc.client.CreateCR(testCtx, expectedD.Name, expectedD))

expectedV := failedVolCR.DeepCopy()
expectedV.Annotations = map[string]string{fakeAttachVolumeAnnotation: fakeAttachVolumeKey}
assert.NotNil(t, expectedV)
expectedV.Spec.OperationalStatus = apiV1.OperationalStatusMissing
assert.Nil(t, dc.client.CreateCR(testCtx, expectedV.Name, expectedV))

err := dc.handleDriveStatus(testCtx, expectedD)
assert.Nil(t, err)
assert.Equal(t, expectedD.Spec.UUID, driveUUID)
assert.Equal(t, expectedD.Spec.Status, apiV1.DriveStatusOnline)
assert.Equal(t, expectedD.Spec.Health, apiV1.HealthBad)
assert.Empty(t, expectedD.Spec.Usage)

resultVolume, err := dc.crHelper.GetVolumesByLocation(testCtx, driveUUID)
assert.Nil(t, err)
assert.NotNil(t, resultVolume)
assert.NotNil(t, resultVolume[0].Spec)
assert.Equal(t, resultVolume[0].Spec.OperationalStatus, apiV1.OperationalStatusMissing)

assert.Nil(t, dc.client.DeleteCR(testCtx, expectedD))
assert.Nil(t, dc.client.DeleteCR(testCtx, expectedV))
})
Expand Down

0 comments on commit 74f93d2

Please sign in to comment.