Skip to content

Commit 6d08361

Browse files
committed
fixed unit tests code coverage
Signed-off-by: Arashad Ahamad <[email protected]>
1 parent 402d3d6 commit 6d08361

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

pkg/ibmcsidriver/controller.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,8 @@ func (csiCS *CSIControllerServer) ListSnapshots(ctx context.Context, req *csi.Li
562562
entries := []*csi.ListSnapshotsResponse_Entry{}
563563
snapshotID := req.GetSnapshotId()
564564
snapID, snapshotAccountID := getSnapshotAndAccountIDsFromCRN(snapshotID)
565-
566-
ctxLogger.Info("*****************************************", zap.Reflect("Node-ACCOUNTID", csiCS.Driver.accountID), zap.Reflect("SNAPHSOTID", snapshotAccountID))
567-
568-
if len(snapID) != 0 && csiCS.Driver.accountID == snapshotAccountID { // in case snapshotID's account and cluster account ID is same
569-
if csiCS.Driver.accountID == snapshotAccountID {
565+
if len(snapID) != 0 {
566+
if csiCS.Driver.accountID == snapshotAccountID { // in case snapshotID's account and cluster account ID is same
570567
snapshot, err := session.GetSnapshot(snapID)
571568
if snapshot == nil {
572569
return &csi.ListSnapshotsResponse{}, nil
@@ -597,7 +594,6 @@ func (csiCS *CSIControllerServer) ListSnapshots(ctx context.Context, req *csi.Li
597594
}
598595

599596
maxEntries := int(req.GetMaxEntries())
600-
ctxLogger.Info("******************************", zap.Reflect("SanpshotMAXENTRIES", req.GetMaxEntries()))
601597
tags := map[string]string{}
602598
sourceVolumeID := req.GetSourceVolumeId()
603599
if len(sourceVolumeID) != 0 {

pkg/ibmcsidriver/controller_helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func getAccountID(input string) string {
472472
}
473473
}
474474

475-
// getSnapshotIDFromCRN ...
475+
// getSnapshotAndAccountIDsFromCRN ...
476476
func getSnapshotAndAccountIDsFromCRN(crn string) (string, string) {
477477
// This method will be able to handle either crn is actual crn or caller passed snapshot ID also
478478
// expected CRN -> crn:v1:service:public:is:us-south:a/c468d8642937fecd8a0860fe0f379bf9::snapshot:r006-1234fe0c-3d9b-4c95-a6d1-8e0d4bcb6ecb

pkg/ibmcsidriver/controller_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,14 @@ func TestListSnapshots(t *testing.T) {
14741474
expErrCode: codes.OK,
14751475
libSnapshotError: nil,
14761476
},
1477+
{
1478+
name: "List snapshot with snapshotID as CRN",
1479+
snapshotID: "crn:v1:staging:public:is:us-south:a/77f2bcedd73fe82c1c::snapshot:r134-1ad4-4852-b24a-b65050e42429",
1480+
expectedEntries: 1,
1481+
libGetSnapshotErr: false,
1482+
expErrCode: codes.OK,
1483+
libSnapshotError: nil,
1484+
},
14771485
}
14781486
timeNow := time.Now()
14791487
// Creating test logger

0 commit comments

Comments
 (0)