This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exclude_test.go
128 lines (112 loc) · 2.51 KB
/
exclude_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package vfs
import "testing"
func TestExclude(t *testing.T) {
{
ns := NewNameSpace()
ns.Bind("/1", Exclude(OS(testPath("B")), "/things/wood/tree"), "/", BindAfter)
assertIsDir(t, ns,
"/1/things/wood/table",
"/1/things",
)
assertIsNotExist(t, ns,
"/1/things/wood/tree",
)
assertWalk(t, ns, ``)
}
{
ns := NewNameSpace()
ns.Bind("/1", Exclude(OS(testPath("B/things")),
"/wood/table",
"/wood/tree/B-tree",
), "/wood/", BindAfter)
assertIsDir(t, ns,
"/1/tree/",
)
assertIsNotExist(t, ns,
"/1/table",
)
assertWalk(t, ns, `dir : /
dir : /1
dir : /1/tree
file: /1/tree/tree
data: B/things/wood/tree/tree`)
assertIsNotExist(t, ns,
"/2/wood/table/",
)
}
}
func TestExcludeFiles(t *testing.T) {
ns := NameSpace{}
ns.Bind("/", NewNameSpace(), "/", BindReplace)
ns.Bind("/1", OS(testPath("B")), "/things", BindAfter)
ns.Bind("/2", Exclude(OS(testPath("B")),
"/things/wood/tree/B-tree",
"/things/wood/table/NOTAFILE",
"/things/wood/table/B-table",
), "/things", BindAfter)
assertOSPather(t, ns, map[string]string{
"/2/wood/table/table": "test-fixtures/B/things/wood/table/table",
"/1/wood": "test-fixtures/B/things/wood",
})
assertWalk(t, ns, `dir : /
dir : /1
dir : /1/wood
dir : /1/wood/table
file: /1/wood/table/B-table
data: B/things/wood/table/B-table
file: /1/wood/table/table
data: B/things/wood/table/table
dir : /1/wood/tree
file: /1/wood/tree/B-tree
data: B/things/wood/tree/B-tree
file: /1/wood/tree/tree
data: B/things/wood/tree/tree
dir : /2
dir : /2/wood
dir : /2/wood/table
file: /2/wood/table/table
data: B/things/wood/table/table
dir : /2/wood/tree
file: /2/wood/tree/tree
data: B/things/wood/tree/tree`)
}
func TestSafeExclude(t *testing.T) {
ns := NewNameSpace()
bindOrDie(t, ns.BindSafe("/",
SafeExclude(SafeOS(testPath("B")),
"/things/wood/table",
"things/wood/tree",
),
"/things", BindAfter))
assertWalk(t, ns, "s")
bindOrDie(t, ns.BindSafe("/a",
SafeExclude(SafeOS(testPath("B")),
"/things/wood/table",
"things/wood/tree",
"/animals/dogs/dogs",
),
"/animals", BindAfter))
assertIsDir(t, ns,
"/wood/",
"/aninmals",
"/dogs",
)
assertIsNotExist(t, ns,
"/2/tree/",
"/2/table/",
)
assertWalk(t, ns, `dir : /
dir : /1
dir : /1/table
file : /1/table/B-table
data : B/things/wood/table/B-table
file : /1/table/table
data : B/things/wood/table/table
dir : /1/tree
file : /1/tree/B-tree
data : B/things/wood/tree/B-tree
file : /1/tree/tree
data : B/things/wood/tree/tree
dir : /2
dir : /2/wood`)
}