From 430abfbdfe6a74476bfeec680616631b22bcab0d Mon Sep 17 00:00:00 2001 From: NickrenREN Date: Thu, 8 Dec 2016 17:30:44 +0800 Subject: [PATCH] cinder attacher GetDeviceMountPath add function to test GetDeviceMountPath func return value --- pkg/volume/cinder/attacher_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/volume/cinder/attacher_test.go b/pkg/volume/cinder/attacher_test.go index 25617b7f2ce..9a55ac7888a 100644 --- a/pkg/volume/cinder/attacher_test.go +++ b/pkg/volume/cinder/attacher_test.go @@ -57,6 +57,27 @@ func TestGetDeviceName_PersistentVolume(t *testing.T) { } } +func TestGetDeviceMountPath(t *testing.T) { + name := "cinder-volume-id" + spec := createVolSpec(name, false) + rootDir := "/var/lib/kubelet/" + host := volumetest.NewFakeVolumeHost(rootDir, nil, nil) + + attacher := &cinderDiskAttacher{ + host: host, + } + + //test the path + path, err := attacher.GetDeviceMountPath(spec) + if err != nil { + t.Errorf("Get device mount path error") + } + expectedPath := rootDir + "plugins/kubernetes.io/cinder/mounts/" + name + if path != expectedPath { + t.Errorf("Device mount path error: expected %s, got %s ", expectedPath, path) + } +} + // One testcase for TestAttachDetach table test below type testcase struct { name string