Skip to content

Commit

Permalink
Fix mount argument tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jjkr committed Nov 7, 2023
1 parent dd24f13 commit 79534b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
// if there is a space between, replace it with an = sign
mountFlags[i] = strings.Replace(strings.Join(strings.Fields(strings.Trim(mountFlags[i], " ")), " "), " ", "=", -1)
// prepend -- if it's not already there
if !strings.HasPrefix(mountFlags[i], "--") {
if !strings.HasPrefix(mountFlags[i], "-") {
mountFlags[i] = "--" + mountFlags[i]
}
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestNodePublishVolume(t *testing.T) {
}

nodeTestEnv.mockMounter.EXPECT().MakeDir(gomock.Eq(targetPath)).Return(nil)
nodeTestEnv.mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(false, 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"}))
_, err := nodeTestEnv.driver.NodePublishVolume(ctx, req)
if err != nil {
Expand Down Expand Up @@ -156,8 +156,10 @@ func TestNodePublishVolume(t *testing.T) {
}

nodeTestEnv.mockMounter.EXPECT().MakeDir(gomock.Eq(targetPath)).Return(nil)
nodeTestEnv.mockMounter.EXPECT().IsLikelyNotMountPoint(gomock.Eq(targetPath)).Return(false, nil)
nodeTestEnv.mockMounter.EXPECT().Mount(gomock.Eq(volumeId), gomock.Eq(targetPath), gomock.Eq("unused"), gomock.Eq([]string{"--test=123", "--foo"}))
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{"--read-only", "--test=123"})).Return(nil)
_, err := nodeTestEnv.driver.NodePublishVolume(ctx, req)
if err != nil {
t.Fatalf("NodePublishVolume is failed: %v", err)
Expand Down

0 comments on commit 79534b5

Please sign in to comment.