-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_test.go
More file actions
57 lines (47 loc) · 1.12 KB
/
file_test.go
File metadata and controls
57 lines (47 loc) · 1.12 KB
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
51
52
53
54
55
56
57
package main
import (
"os"
"testing"
)
func Test_newFileAccess(t *testing.T) {
curDir, _ := os.Getwd()
fa := newFileAccess(curDir)
normalizedCurDir := normalizePath(curDir, true)
if fa.srcPath != normalizedCurDir {
t.Error("srcPath should be set correctly")
}
}
func Test_FileAccess_EachSource_Dir(t *testing.T) {
curDir, _ := os.Getwd()
fa := newFileAccess(curDir)
count := 0
fa.EachSource(func(fs FileSource) error {
count++
return nil
})
if count < 5 {
t.Error("file EachSource failed.")
}
}
func Test_FileAccess_EachSource_File(t *testing.T) {
curDir, _ := os.Getwd()
fa := newFileAccess(curDir + "/file_test.go")
count := 0
subPath := "x"
isDir := false
fa.EachSource(func(fs FileSource) error {
count++
subPath = fs.SubPath()
isDir = fs.IsDir()
return nil
})
if count != 1 {
t.Error("file EachSource failed.")
}
if subPath != "" {
t.Error("file should not have a sub path")
}
if isDir {
t.Error("file should return false for IsDir")
}
}