From 74f93d2582a918f9634319c32036188269ca37a7 Mon Sep 17 00:00:00 2001 From: katarzynakulpa Date: Tue, 9 Jul 2024 15:01:08 +0200 Subject: [PATCH] [issue-1198] adding tests Signed-off-by: katarzynakulpa --- .../drive/drivecontroller_test.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/crcontrollers/drive/drivecontroller_test.go b/pkg/crcontrollers/drive/drivecontroller_test.go index f646cc621..498074f06 100644 --- a/pkg/crcontrollers/drive/drivecontroller_test.go +++ b/pkg/crcontrollers/drive/drivecontroller_test.go @@ -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)) })