add a clean code for TestCanSupport

update other location

forgot two files need to be updated
This commit is contained in:
guangxuli
2016-10-08 16:58:56 +08:00
parent 88c11d4b79
commit 2c9e84f50f
3 changed files with 16 additions and 10 deletions

View File

@@ -249,7 +249,8 @@ func newTestHost(t *testing.T, clientset clientset.Interface) (string, volume.Vo
func TestCanSupport(t *testing.T) {
pluginMgr := volume.VolumePluginMgr{}
_, host := newTestHost(t, nil)
tempDir, host := newTestHost(t, nil)
defer os.RemoveAll(tempDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
@@ -274,13 +275,14 @@ func TestPlugin(t *testing.T) {
testNamespace = "test_configmap_namespace"
testName = "test_configmap_name"
volumeSpec = volumeSpec(testVolumeName, testName, 0644)
configMap = configMap(testNamespace, testName)
client = fake.NewSimpleClientset(&configMap)
pluginMgr = volume.VolumePluginMgr{}
_, host = newTestHost(t, client)
volumeSpec = volumeSpec(testVolumeName, testName, 0644)
configMap = configMap(testNamespace, testName)
client = fake.NewSimpleClientset(&configMap)
pluginMgr = volume.VolumePluginMgr{}
tempDir, host = newTestHost(t, client)
)
defer os.RemoveAll(tempDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
@@ -344,6 +346,7 @@ func TestPluginReboot(t *testing.T) {
rootDir, host = newTestHost(t, client)
)
defer os.RemoveAll(rootDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)

View File

@@ -43,7 +43,8 @@ func newTestHost(t *testing.T) (string, volume.VolumeHost) {
func TestCanSupport(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
_, host := newTestHost(t)
tempDir, host := newTestHost(t)
defer os.RemoveAll(tempDir)
plugMgr.InitPlugins(ProbeVolumePlugins(), host)
plug, err := plugMgr.FindPluginByName("kubernetes.io/git-repo")
@@ -221,6 +222,7 @@ func doTestPlugin(scenario struct {
plugMgr := volume.VolumePluginMgr{}
rootDir, host := newTestHost(t)
defer os.RemoveAll(rootDir)
plugMgr.InitPlugins(ProbeVolumePlugins(), host)
plug, err := plugMgr.FindPluginByName("kubernetes.io/git-repo")

View File

@@ -252,7 +252,8 @@ func newTestHost(t *testing.T, clientset clientset.Interface) (string, volume.Vo
func TestCanSupport(t *testing.T) {
pluginMgr := volume.VolumePluginMgr{}
_, host := newTestHost(t, nil)
tempDir, host := newTestHost(t, nil)
defer os.RemoveAll(tempDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(secretPluginName)
@@ -283,7 +284,7 @@ func TestPlugin(t *testing.T) {
pluginMgr = volume.VolumePluginMgr{}
rootDir, host = newTestHost(t, client)
)
defer os.RemoveAll(rootDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(secretPluginName)
@@ -356,7 +357,7 @@ func TestPluginReboot(t *testing.T) {
pluginMgr = volume.VolumePluginMgr{}
rootDir, host = newTestHost(t, client)
)
defer os.RemoveAll(rootDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(secretPluginName)