From 50aea58462abb926245d9ec73fa9e9f7e5e627bf Mon Sep 17 00:00:00 2001 From: elijah quinones Date: Mon, 5 Aug 2024 20:25:44 +0000 Subject: [PATCH] fix spelling and formating issues, add addtional test case, and remove todo comments --- pkg/cloud/cloud_test.go | 6 +++--- pkg/driver/controller.go | 4 ---- pkg/driver/controller_modify_volume_test.go | 18 ++++++++++++++++++ pkg/driver/driver.go | 4 ---- pkg/driver/driver_test.go | 1 - pkg/driver/validation_test.go | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pkg/cloud/cloud_test.go b/pkg/cloud/cloud_test.go index a530dbf368..c836788430 100644 --- a/pkg/cloud/cloud_test.go +++ b/pkg/cloud/cloud_test.go @@ -92,21 +92,21 @@ func TestNewCloud(t *testing.T) { batchingEnabled bool }{ { - name: "sucess with debug,userAgentExtra and batching", + name: "success: with debug, userAgentExtra, and batching", region: "us-east-1", awsSdkDebugLog: true, userAgentExtra: "example_user_agent_extra", batchingEnabled: true, }, { - name: "sucess with only debug and userAgenrExtra", + name: "success: with only debug, and userAgentExtra", region: "us-east-1", awsSdkDebugLog: true, userAgentExtra: "example_user_agent_extra", batchingEnabled: false, }, { - name: "sucess with only region", + name: "success: with only region", region: "us-east-1", awsSdkDebugLog: false, userAgentExtra: "", diff --git a/pkg/driver/controller.go b/pkg/driver/controller.go index de6bcffe8b..7b460fd6f2 100644 --- a/pkg/driver/controller.go +++ b/pkg/driver/controller.go @@ -130,10 +130,6 @@ func (d *ControllerService) CreateVolume(ctx context.Context, req *csi.CreateVol for key, value := range req.GetParameters() { switch strings.ToLower(key) { - // we tell user here that they should use csi.storage.k8s.io/fstype instead but there is no switch cases to handle that - // Suggestion to add case FSTypeKey that will set the fstype and in the case "fstype" we print the warning and still set - // fstype for them - case "fstype": klog.InfoS("\"fstype\" is deprecated, please use \"csi.storage.k8s.io/fstype\" instead") case VolumeTypeKey: diff --git a/pkg/driver/controller_modify_volume_test.go b/pkg/driver/controller_modify_volume_test.go index ee47610266..74fc464fd1 100644 --- a/pkg/driver/controller_modify_volume_test.go +++ b/pkg/driver/controller_modify_volume_test.go @@ -47,6 +47,24 @@ func TestMergeModifyVolumeRequest(t *testing.T) { expectedModifyVolumeRequest modifyVolumeRequest expectError bool }{ + { + name: "Valid merge of size and iops", + input: modifyVolumeRequest{ + newSize: 5, + }, + existing: modifyVolumeRequest{ + modifyDiskOptions: cloud.ModifyDiskOptions{ + IOPS: validIopsInt, + }, + }, + expectedModifyVolumeRequest: modifyVolumeRequest{ + newSize: 5, + modifyDiskOptions: cloud.ModifyDiskOptions{ + IOPS: validIopsInt, + }, + }, + expectError: false, + }, { name: "Different size requested by a previous request", input: modifyVolumeRequest{ diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index 83fabc6831..af74a919d0 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -84,10 +84,6 @@ func NewDriver(c cloud.Cloud, o *Options, m mounter.Mounter, md metadata.Metadat case AllMode: driver.controller = NewControllerService(c, o) driver.node = NewNodeService(o, md, m, k) - /*TODO is the default case even possible to occur if we have a node mode that is not controller driver or all it will return - an error on line 71 as ValidateDriverOptions calls to ValidateMode which only allows the contoller node and all modes or it will - return an error - */ default: return nil, fmt.Errorf("unknown mode: %s", o.Mode) } diff --git a/pkg/driver/driver_test.go b/pkg/driver/driver_test.go index 642f70f737..73c44abbee 100644 --- a/pkg/driver/driver_test.go +++ b/pkg/driver/driver_test.go @@ -85,7 +85,6 @@ func TestNewDriver(t *testing.T) { } if tc.hasController && driver.controller == nil { t.Fatalf("Expected driver to have controller but driver does not have controller") - } if tc.expectError { require.Error(t, err) diff --git a/pkg/driver/validation_test.go b/pkg/driver/validation_test.go index 8abd50c649..95aa81f16c 100644 --- a/pkg/driver/validation_test.go +++ b/pkg/driver/validation_test.go @@ -69,7 +69,7 @@ func TestValidateExtraTags(t *testing.T) { { name: "invaid tag: key is empty", tags: map[string]string{ - randomString(cloud.MinTagKeyLength - 1): "extra-tag-value", + "": "extra-tag-value", }, expErr: fmt.Errorf("Tag key cannot be empty (min: 1)"), },