Skip to content

Commit

Permalink
More test on helpers validate path
Browse files Browse the repository at this point in the history
  • Loading branch information
0x19 committed Aug 19, 2023
1 parent d5faac4 commit 176d082
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func TestValidatePath(t *testing.T) {
tempFile.Close()
defer os.Remove(tempFile.Name())

// Create a directory with no read permissions
unreadableDir, err := os.MkdirTemp("", "test_unreadable")
if err != nil {
t.Fatalf("Failed to create unreadable directory: %v", err)
}
defer os.RemoveAll(unreadableDir)
os.Chmod(unreadableDir, 0222) // Write-only permissions

tests := []struct {
name string
path string
Expand All @@ -42,6 +50,11 @@ func TestValidatePath(t *testing.T) {
path: tempFile.Name(),
wantErr: "path is not a directory",
},
{
name: "Unreadable Directory",
path: unreadableDir,
wantErr: "directory is not readable",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 176d082

Please sign in to comment.