mirror of https://github.com/k3s-io/k3s
parent
b87a392b1a
commit
3db442bcd0
|
@ -139,7 +139,14 @@ func TestGetMountRefs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDoSafeMakeDir(t *testing.T) {
|
func TestDoSafeMakeDir(t *testing.T) {
|
||||||
const testingVolumePath = `c:\tmp\DoSafeMakeDirTest`
|
base, err := ioutil.TempDir("", "TestDoSafeMakeDir")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
defer os.RemoveAll(base)
|
||||||
|
|
||||||
|
testingVolumePath := filepath.Join(base, "testingVolumePath")
|
||||||
os.MkdirAll(testingVolumePath, 0755)
|
os.MkdirAll(testingVolumePath, 0755)
|
||||||
defer os.RemoveAll(testingVolumePath)
|
defer os.RemoveAll(testingVolumePath)
|
||||||
|
|
||||||
|
@ -171,7 +178,7 @@ func TestDoSafeMakeDir(t *testing.T) {
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
subPath: filepath.Join(testingVolumePath, `symlink`),
|
subPath: filepath.Join(testingVolumePath, `symlink`),
|
||||||
expectError: false,
|
expectError: false,
|
||||||
symlinkTarget: `c:\tmp`,
|
symlinkTarget: base,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
|
@ -189,7 +196,7 @@ func TestDoSafeMakeDir(t *testing.T) {
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
subPath: filepath.Join(testingVolumePath, `a\b\symlink`),
|
subPath: filepath.Join(testingVolumePath, `a\b\symlink`),
|
||||||
expectError: false,
|
expectError: false,
|
||||||
symlinkTarget: `c:\tmp`,
|
symlinkTarget: base,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
|
@ -228,7 +235,14 @@ func TestDoSafeMakeDir(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLockAndCheckSubPath(t *testing.T) {
|
func TestLockAndCheckSubPath(t *testing.T) {
|
||||||
const testingVolumePath = `c:\tmp\LockAndCheckSubPathTest`
|
base, err := ioutil.TempDir("", "TestLockAndCheckSubPath")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
defer os.RemoveAll(base)
|
||||||
|
|
||||||
|
testingVolumePath := filepath.Join(base, "testingVolumePath")
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
volumePath string
|
volumePath string
|
||||||
|
@ -270,14 +284,14 @@ func TestLockAndCheckSubPath(t *testing.T) {
|
||||||
subPath: filepath.Join(testingVolumePath, `symlink`),
|
subPath: filepath.Join(testingVolumePath, `symlink`),
|
||||||
expectedHandleCount: 0,
|
expectedHandleCount: 0,
|
||||||
expectError: true,
|
expectError: true,
|
||||||
symlinkTarget: `c:\tmp`,
|
symlinkTarget: base,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`),
|
subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`),
|
||||||
expectedHandleCount: 0,
|
expectedHandleCount: 0,
|
||||||
expectError: true,
|
expectError: true,
|
||||||
symlinkTarget: `c:\tmp`,
|
symlinkTarget: base,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
|
@ -325,7 +339,14 @@ func TestLockAndCheckSubPath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
|
func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
|
||||||
const testingVolumePath = `c:\tmp\LockAndCheckSubPathWithoutSymlinkTest`
|
base, err := ioutil.TempDir("", "TestLockAndCheckSubPathWithoutSymlink")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
defer os.RemoveAll(base)
|
||||||
|
|
||||||
|
testingVolumePath := filepath.Join(base, "testingVolumePath")
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
volumePath string
|
volumePath string
|
||||||
|
@ -367,14 +388,14 @@ func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
|
||||||
subPath: filepath.Join(testingVolumePath, `symlink`),
|
subPath: filepath.Join(testingVolumePath, `symlink`),
|
||||||
expectedHandleCount: 1,
|
expectedHandleCount: 1,
|
||||||
expectError: true,
|
expectError: true,
|
||||||
symlinkTarget: `c:\tmp`,
|
symlinkTarget: base,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`),
|
subPath: filepath.Join(testingVolumePath, `a\b\c\symlink`),
|
||||||
expectedHandleCount: 4,
|
expectedHandleCount: 4,
|
||||||
expectError: true,
|
expectError: true,
|
||||||
symlinkTarget: `c:\tmp`,
|
symlinkTarget: base,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumePath: testingVolumePath,
|
volumePath: testingVolumePath,
|
||||||
|
@ -422,7 +443,14 @@ func TestLockAndCheckSubPathWithoutSymlink(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindExistingPrefix(t *testing.T) {
|
func TestFindExistingPrefix(t *testing.T) {
|
||||||
const testingVolumePath = `c:\tmp\FindExistingPrefixTest`
|
base, err := ioutil.TempDir("", "TestFindExistingPrefix")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
defer os.RemoveAll(base)
|
||||||
|
|
||||||
|
testingVolumePath := filepath.Join(base, "testingVolumePath")
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
base string
|
base string
|
||||||
|
|
Loading…
Reference in New Issue