Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional mount unittest #484

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions pkg/driver/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func TestMakeDir(t *testing.T) {
t.Fatalf("Expect no error but got: %v", err)
}

if mountObj.MakeDir(targetPath) != nil {
gliptak marked this conversation as resolved.
Show resolved Hide resolved
t.Fatalf("Expect no error but got: %v", err)
}

if exists, err := mountObj.ExistsPath(targetPath); !exists {
t.Fatalf("Expect no error but got: %v", err)
}
Expand All @@ -64,8 +68,58 @@ func TestMakeFile(t *testing.T) {
t.Fatalf("Expect no error but got: %v", err)
}

if mountObj.MakeFile(targetPath) != nil {
gliptak marked this conversation as resolved.
Show resolved Hide resolved
t.Fatalf("Expect no error but got: %v", err)
}

if exists, err := mountObj.ExistsPath(targetPath); !exists {
t.Fatalf("Expect no error but got: %v", err)
}

}

func TestExistsPath(t *testing.T) {
leakingtapan marked this conversation as resolved.
Show resolved Hide resolved
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "mount-ebs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
defer os.RemoveAll(dir)

targetPath := filepath.Join(dir, "notafile")

var (
mountObj = newNodeMounter()
)

exists, err := mountObj.ExistsPath(targetPath)

if err != nil {
t.Fatalf("Expect no error but got: %v", err)
}

if exists {
t.Fatalf("Expected file %s to not exist", targetPath)
}

}

func TestGetDeviceName(t *testing.T) {
// Setup the full driver and its environment
dir, err := ioutil.TempDir("", "mount-ebs-csi")
if err != nil {
t.Fatalf("error creating directory %v", err)
}
defer os.RemoveAll(dir)

targetPath := filepath.Join(dir, "notafile")

var (
mountObj = newNodeMounter()
)

if _, _, err := mountObj.GetDeviceName(targetPath); err != nil {
t.Fatalf("Expect no error but got: %v", err)
}

}