-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathhelpers_test.go
More file actions
50 lines (46 loc) · 785 Bytes
/
Copy pathhelpers_test.go
File metadata and controls
50 lines (46 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package caddywaf
import (
"os"
"testing"
)
func TestFileExists(t *testing.T) {
// Create a temporary test file
tmpFile, err := os.CreateTemp("", "test")
if err != nil {
t.Fatal(err)
}
defer os.Remove(tmpFile.Name())
tests := []struct {
name string
path string
want bool
}{
{
name: "empty path",
path: "",
want: false,
},
{
name: "non-existent file",
path: "/path/to/nonexistent/file",
want: false,
},
{
name: "existing file",
path: tmpFile.Name(),
want: true,
},
{
name: "directory",
path: os.TempDir(),
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := fileExists(tt.path); got != tt.want {
t.Errorf("fileExists() = %v, want %v", got, tt.want)
}
})
}
}