Skip to content

Commit

Permalink
Fixing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dlakhaws committed Oct 19, 2023
1 parent d4ab85e commit 43d9cdd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/cloud/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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"}))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 43d9cdd

Please sign in to comment.