Skip to content

Commit

Permalink
first test
Browse files Browse the repository at this point in the history
  • Loading branch information
fenio committed Jun 29, 2024
1 parent 469a56b commit d24e633
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pkg/plugin/mount_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package plugin

import (
"os"
"testing"
)

func TestValidateMountPoint(t *testing.T) {
t.Run("Mount point exists", func(t *testing.T) {
// Create a temporary directory to simulate an existing mount point
tempDir := t.TempDir()

// Call the function
err := validateMountPoint(tempDir)

// Check the result
if err != nil {
t.Errorf("validateMountPoint(%s) returned an unexpected error: %v", tempDir, err)
}
})

t.Run("Mount point does not exist", func(t *testing.T) {
// Define a path that does not exist
nonExistentPath := "/path/that/does/not/exist"

// Call the function
err := validateMountPoint(nonExistentPath)

// Check the result
if err == nil {
t.Errorf("validateMountPoint(%s) should have returned an error, but it did not", nonExistentPath)
}
})
}

func TestValidateMountPoint_FileInsteadOfDirectory(t *testing.T) {
// Create a temporary file to simulate a file instead of a directory
tempFile, err := os.CreateTemp("", "testfile")
if err != nil {
t.Fatalf("Failed to create temporary file: %v", err)
}
defer os.Remove(tempFile.Name())

// Call the function
err = validateMountPoint(tempFile.Name())

// Check the result
if err != nil {
t.Errorf("validateMountPoint(%s) returned an unexpected error: %v", tempFile.Name(), err)
}
}

0 comments on commit d24e633

Please sign in to comment.