Move 'path' package usage to 'path/filepath'

This commit is contained in:
Yuki Ueda
2020-02-05 14:29:27 +09:00
parent 133f77247c
commit d1bc1875aa
2 changed files with 7 additions and 9 deletions

View File

@@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"os" "os"
"path"
"path/filepath" "path/filepath"
"testing" "testing"
@@ -376,7 +375,7 @@ func TestPluginConstructVolumeSpec(t *testing.T) {
csiMounter := mounter.(*csiMountMgr) csiMounter := mounter.(*csiMountMgr)
// rebuild spec // rebuild spec
spec, err := plug.ConstructVolumeSpec("test-pv", path.Dir(csiMounter.GetPath())) spec, err := plug.ConstructVolumeSpec("test-pv", filepath.Dir(csiMounter.GetPath()))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -508,7 +507,7 @@ func TestPluginConstructVolumeSpecWithInline(t *testing.T) {
csiMounter := mounter.(*csiMountMgr) csiMounter := mounter.(*csiMountMgr)
// rebuild spec // rebuild spec
spec, err := plug.ConstructVolumeSpec("test-pv", path.Dir(csiMounter.GetPath())) spec, err := plug.ConstructVolumeSpec("test-pv", filepath.Dir(csiMounter.GetPath()))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -636,7 +635,7 @@ func TestPluginNewMounter(t *testing.T) {
} }
// ensure data file is created // ensure data file is created
dataDir := path.Dir(mounter.GetPath()) dataDir := filepath.Dir(mounter.GetPath())
dataFile := filepath.Join(dataDir, volDataFileName) dataFile := filepath.Join(dataDir, volDataFileName)
if _, err := os.Stat(dataFile); err != nil { if _, err := os.Stat(dataFile); err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
@@ -775,7 +774,7 @@ func TestPluginNewMounterWithInline(t *testing.T) {
} }
// ensure data file is created // ensure data file is created
dataDir := path.Dir(mounter.GetPath()) dataDir := filepath.Dir(mounter.GetPath())
dataFile := filepath.Join(dataDir, volDataFileName) dataFile := filepath.Join(dataDir, volDataFileName)
if _, err := os.Stat(dataFile); err != nil { if _, err := os.Stat(dataFile); err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
@@ -834,7 +833,7 @@ func TestPluginNewUnmounter(t *testing.T) {
} }
if err := saveVolumeData( if err := saveVolumeData(
path.Dir(dir), filepath.Dir(dir),
volDataFileName, volDataFileName,
map[string]string{ map[string]string{
volDataKey.specVolID: pv.ObjectMeta.Name, volDataKey.specVolID: pv.ObjectMeta.Name,

View File

@@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"os" "os"
"path"
"path/filepath" "path/filepath"
"testing" "testing"
"time" "time"
@@ -422,14 +421,14 @@ func TestCSI_VolumeAll(t *testing.T) {
} }
t.Log("csiTest.VolumeAll mounter.Setup(fsGroup) done OK") t.Log("csiTest.VolumeAll mounter.Setup(fsGroup) done OK")
dataFile := filepath.Join(path.Dir(mounter.GetPath()), volDataFileName) dataFile := filepath.Join(filepath.Dir(mounter.GetPath()), volDataFileName)
if _, err := os.Stat(dataFile); err != nil { if _, err := os.Stat(dataFile); err != nil {
t.Fatalf("csiTest.VolumeAll meatadata JSON file not found: %s", dataFile) t.Fatalf("csiTest.VolumeAll meatadata JSON file not found: %s", dataFile)
} }
t.Log("csiTest.VolumeAll JSON datafile generated OK:", dataFile) t.Log("csiTest.VolumeAll JSON datafile generated OK:", dataFile)
// ******** Volume Reconstruction ************* // // ******** Volume Reconstruction ************* //
volPath := path.Dir(csiMounter.GetPath()) volPath := filepath.Dir(csiMounter.GetPath())
t.Log("csiTest.VolumeAll entering plugin.ConstructVolumeSpec for path", volPath) t.Log("csiTest.VolumeAll entering plugin.ConstructVolumeSpec for path", volPath)
spec, err := volPlug.ConstructVolumeSpec(test.volName, volPath) spec, err := volPlug.ConstructVolumeSpec(test.volName, volPath)
if err != nil { if err != nil {