Skip to content

Commit

Permalink
Merge pull request #484 from gliptak/coverage2
Browse files Browse the repository at this point in the history
Additional mount unittest
  • Loading branch information
k8s-ci-robot authored Apr 16, 2020
2 parents d7c0077 + 0cc7425 commit 04f0e8a
Showing 1 changed file with 54 additions and 0 deletions.
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 {
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 {
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) {
// 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)
}

}

0 comments on commit 04f0e8a

Please sign in to comment.