-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathfile_test.go
56 lines (44 loc) · 1.4 KB
/
file_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
50
51
52
53
54
55
56
package faker
import (
"os"
"strings"
"testing"
)
func TestExtension(t *testing.T) {
p := New().File()
Expect(t, true, p.Extension() != "")
}
func TestFileWithExtension(t *testing.T) {
p := New().File()
Expect(t, true, len(strings.Split(p.FilenameWithExtension(), ".")) == 2)
}
func TestAbsolutePath(t *testing.T) {
p := New().File()
path := p.AbsoluteFilePath(2)
parts := strings.Split(path, string(os.PathSeparator))
Expect(t, true, isUnixPath(path) || isWindowsPath(path))
Expect(t, true, len(parts) == 4)
Expect(t, true, len(strings.Split(parts[len(parts)-1], ".")) == 2)
p.OSResolver = WindowsOSResolver{}
path = p.AbsoluteFilePath(2)
parts = strings.Split(path, "\\")
Expect(t, true, isWindowsPath(p.AbsoluteFilePath(2)))
Expect(t, true, len(parts) == 4)
Expect(t, true, len(strings.Split(parts[len(parts)-1], ".")) == 2)
}
func TestAbsoluteFilePathForUnix(t *testing.T) {
p := New().File()
path := p.AbsoluteFilePathForUnix(2)
parts := strings.Split(path, "/")
Expect(t, true, isUnixPath(path))
Expect(t, true, len(parts) == 4)
Expect(t, true, len(strings.Split(parts[len(parts)-1], ".")) == 2)
}
func TestAbsoluteFilePathForWindows(t *testing.T) {
p := New().File()
path := p.AbsoluteFilePathForWindows(2)
parts := strings.Split(path, "\\")
Expect(t, true, isWindowsPath(path))
Expect(t, true, len(parts) == 4)
Expect(t, true, len(strings.Split(parts[len(parts)-1], ".")) == 2)
}