Skip to content

Commit 1efa778

Browse files
committed
test: add ut
fix fix
1 parent 0e4e10c commit 1efa778

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

pkg/smb/nodeserver_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,35 @@ func TestNodePublishVolume(t *testing.T) {
413413
Readonly: true},
414414
expectedErr: testutil.TestError{},
415415
},
416+
{
417+
desc: "[Error] failed to create ephemeral Volume",
418+
req: &csi.NodePublishVolumeRequest{VolumeCapability: &csi.VolumeCapability{AccessMode: &volumeCap},
419+
VolumeId: "vol_1",
420+
TargetPath: targetTest,
421+
StagingTargetPath: sourceTest,
422+
Readonly: true,
423+
VolumeContext: map[string]string{ephemeralField: "true"},
424+
},
425+
expectedErr: testutil.TestError{
426+
DefaultError: status.Error(codes.InvalidArgument, "source field is missing, current context: map[csi.storage.k8s.io/ephemeral:true secretnamespace:]"),
427+
},
428+
},
429+
{
430+
desc: "[Success] Valid request with ephemeral Volume",
431+
req: &csi.NodePublishVolumeRequest{VolumeCapability: &csi.VolumeCapability{AccessMode: &volumeCap},
432+
VolumeId: "vol_1",
433+
TargetPath: targetTest,
434+
StagingTargetPath: sourceTest,
435+
Readonly: true,
436+
VolumeContext: map[string]string{
437+
ephemeralField: "true",
438+
sourceField: "source",
439+
podNamespaceField: "podnamespace",
440+
},
441+
},
442+
skipOnWindows: true,
443+
expectedErr: testutil.TestError{},
444+
},
416445
}
417446

418447
// Setup

test/e2e/testsuites/testsuites.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,13 @@ func CopyTestSecret(ctx context.Context, c clientset.Interface, sourceNamespace
724724
return &TestSecret{
725725
client: c,
726726
namespace: targetNamespace,
727-
secret: secret,
727+
secret: &v1.Secret{
728+
ObjectMeta: metav1.ObjectMeta{
729+
Name: secretName,
730+
},
731+
StringData: secret.StringData,
732+
Type: v1.SecretTypeOpaque,
733+
},
728734
}
729735
}
730736

0 commit comments

Comments
 (0)