From 55ffd9d5fca3b67c3a511a989dd816350a626b87 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 9 Nov 2020 19:08:20 +0100 Subject: [PATCH] Add unit test for staging path creation --- pkg/volume/csi/csi_attacher_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/volume/csi/csi_attacher_test.go b/pkg/volume/csi/csi_attacher_test.go index 7cb15a929eb..3adf621c507 100644 --- a/pkg/volume/csi/csi_attacher_test.go +++ b/pkg/volume/csi/csi_attacher_test.go @@ -1236,6 +1236,18 @@ func TestAttacherMountDevice(t *testing.T) { t.Errorf("expected mount options: %v, got: %v", tc.spec.PersistentVolume.Spec.MountOptions, vol.MountFlags) } } + + // Verify the deviceMountPath was created by the plugin + if tc.stageUnstageSet { + s, err := os.Stat(tc.deviceMountPath) + if err != nil { + t.Errorf("expected staging directory %s to be created and be a directory, got error: %s", tc.deviceMountPath, err) + } else { + if !s.IsDir() { + t.Errorf("expected staging directory %s to be directory, got something else", tc.deviceMountPath) + } + } + } }) } }