From 43d9cdd12c498173cfba62bc1d5536f8ef1a40c6 Mon Sep 17 00:00:00 2001 From: Dev Lakhia Date: Thu, 19 Oct 2023 11:53:57 +0000 Subject: [PATCH] Fixing unit tests --- pkg/cloud/metadata_test.go | 2 +- pkg/driver/node_test.go | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/cloud/metadata_test.go b/pkg/cloud/metadata_test.go index 1b80b24c..6f5525cb 100644 --- a/pkg/cloud/metadata_test.go +++ b/pkg/cloud/metadata_test.go @@ -169,7 +169,7 @@ func TestNewMetadataService(t *testing.T) { if !tc.isEC2Available { os.Setenv("CSI_NODE_NAME", nodeName) } - m, err := NewMetadataService(ec2MetadataClient, k8sAPIClient, stdRegion) + m, err := NewMetadataService(ec2MetadataClient, k8sAPIClient, "") if err == nil && !tc.isPartial { if tc.err != nil { t.Fatalf("NewMetadataService() failed: expected no error, got %v", err) diff --git a/pkg/driver/node_test.go b/pkg/driver/node_test.go index fc0160da..ed8cd7a6 100644 --- a/pkg/driver/node_test.go +++ b/pkg/driver/node_test.go @@ -3,14 +3,11 @@ package driver import ( "errors" "io/fs" - "os" "testing" - "github.com/awslabs/aws-s3-csi-driver/pkg/cloud" mock_driver "github.com/awslabs/aws-s3-csi-driver/pkg/driver/mocks" csi "github.com/container-storage-interface/spec/lib/go/csi" "github.com/golang/mock/gomock" - "github.com/stretchr/testify/assert" "golang.org/x/net/context" ) @@ -142,9 +139,6 @@ func TestNodePublishVolume(t *testing.T) { TargetPath: targetPath, Readonly: true, } - str, boo := os.LookupEnv(cloud.MP_EC2_METADATA_DISABLED_ENV_VAR) - assert.Equal(t, str, "true") - assert.Equal(t, boo, true) nodeTestEnv.mockMounter.EXPECT().MakeDir(gomock.Eq(targetPath)).Return(nil) nodeTestEnv.mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, nil) nodeTestEnv.mockMounter.EXPECT().Mount(gomock.Eq(volumeId), gomock.Eq(targetPath), gomock.Eq("unused"), gomock.Eq([]string{"--bar", "--foo", "--read-only", "--test=123"})) @@ -177,9 +171,6 @@ func TestNodePublishVolume(t *testing.T) { nodeTestEnv.mockMounter.EXPECT().MakeDir(gomock.Eq(targetPath)).Return(nil) nodeTestEnv.mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(true, nil) nodeTestEnv.mockMounter.EXPECT().Mount(gomock.Eq(volumeId), gomock.Eq(targetPath), gomock.Eq("unused"), gomock.Eq([]string{"AWS_EC2_METADATA_DISABLED"})) - str, boo := os.LookupEnv(cloud.MP_EC2_METADATA_DISABLED_ENV_VAR) - assert.Equal(t, str, "true") - assert.Equal(t, boo, true) _, err := nodeTestEnv.driver.NodePublishVolume(ctx, req) if err != nil { t.Fatalf("NodePublishVolume is failed: %v", err)