-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
directory_test.go
49 lines (37 loc) · 970 Bytes
/
directory_test.go
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
package faker
import (
"regexp"
"strings"
"testing"
)
func isUnixPath(path string) bool {
return path[0] == '/'
}
func isWindowsPath(path string) bool {
return regexp.MustCompile(`^[a-zA-Z]:\\`).MatchString(path[:3])
}
func TestDirectory(t *testing.T) {
p := New().Directory()
dir := p.Directory(2)
Expect(t, true, isUnixPath(dir) || isWindowsPath(dir))
p.OSResolver = WindowsOSResolver{}
Expect(t, true, isWindowsPath(p.Directory(2)))
}
func TestUnixDirectory(t *testing.T) {
p := New().Directory()
dir := p.UnixDirectory(2)
parts := strings.Split(dir, "/")
Expect(t, true, len(parts) == 3)
Expect(t, true, isUnixPath(dir))
}
func TestWindowsDirectory(t *testing.T) {
p := New().Directory()
dir := p.WindowsDirectory(2)
parts := strings.Split(dir, "\\")
Expect(t, true, len(parts) == 3)
Expect(t, true, isWindowsPath(dir))
}
func TestDriveLetter(t *testing.T) {
p := New().Directory()
Expect(t, true, isWindowsPath(p.DriveLetter()))
}