@@ -16,11 +16,12 @@ func TestResolve(t *testing.T) {
16
16
ctrl := gomock .NewController (t )
17
17
18
18
t .Run ("NullByte" , func (t * testing.T ) {
19
- _ , err := path .NewUNIXParser ("hello\x00 world" )
19
+ scopeWalker := mock .NewMockScopeWalker (ctrl )
20
+
20
21
require .Equal (
21
22
t ,
22
23
status .Error (codes .InvalidArgument , "Path contains a null byte" ),
23
- err ,
24
+ path . Resolve ( path . NewUNIXParser ( "hello \x00 world" ), scopeWalker ) ,
24
25
)
25
26
})
26
27
@@ -29,15 +30,15 @@ func TestResolve(t *testing.T) {
29
30
componentWalker := mock .NewMockComponentWalker (ctrl )
30
31
scopeWalker .EXPECT ().OnRelative ().Return (componentWalker , nil )
31
32
32
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("" ), scopeWalker ))
33
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("" ), scopeWalker ))
33
34
})
34
35
35
36
t .Run ("Dot" , func (t * testing.T ) {
36
37
scopeWalker := mock .NewMockScopeWalker (ctrl )
37
38
componentWalker := mock .NewMockComponentWalker (ctrl )
38
39
scopeWalker .EXPECT ().OnRelative ().Return (componentWalker , nil )
39
40
40
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("." ), scopeWalker ))
41
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("." ), scopeWalker ))
41
42
})
42
43
43
44
t .Run ("SingleFileRelative" , func (t * testing.T ) {
@@ -46,7 +47,7 @@ func TestResolve(t *testing.T) {
46
47
scopeWalker .EXPECT ().OnRelative ().Return (componentWalker , nil )
47
48
componentWalker .EXPECT ().OnTerminal (path .MustNewComponent ("hello" ))
48
49
49
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("hello" ), scopeWalker ))
50
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("hello" ), scopeWalker ))
50
51
})
51
52
52
53
t .Run ("SingleFileAbsolute" , func (t * testing.T ) {
@@ -55,7 +56,7 @@ func TestResolve(t *testing.T) {
55
56
scopeWalker .EXPECT ().OnAbsolute ().Return (componentWalker , nil )
56
57
componentWalker .EXPECT ().OnTerminal (path .MustNewComponent ("hello" ))
57
58
58
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("/hello" ), scopeWalker ))
59
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("/hello" ), scopeWalker ))
59
60
})
60
61
61
62
t .Run ("SingleDirectoryWithSlash" , func (t * testing.T ) {
@@ -66,7 +67,7 @@ func TestResolve(t *testing.T) {
66
67
componentWalker1 .EXPECT ().OnDirectory (path .MustNewComponent ("hello" )).
67
68
Return (path.GotDirectory {Child : componentWalker2 }, nil )
68
69
69
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("hello/" ), scopeWalker ))
70
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("hello/" ), scopeWalker ))
70
71
})
71
72
72
73
t .Run ("SingleDirectoryWithSlashDot" , func (t * testing.T ) {
@@ -77,7 +78,7 @@ func TestResolve(t *testing.T) {
77
78
componentWalker1 .EXPECT ().OnDirectory (path .MustNewComponent ("hello" )).
78
79
Return (path.GotDirectory {Child : componentWalker2 }, nil )
79
80
80
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("hello/." ), scopeWalker ))
81
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("hello/." ), scopeWalker ))
81
82
})
82
83
83
84
t .Run ("MultipleComponents" , func (t * testing.T ) {
@@ -99,7 +100,7 @@ func TestResolve(t *testing.T) {
99
100
componentWalker5 .EXPECT ().OnUp ().Return (componentWalker6 , nil )
100
101
componentWalker6 .EXPECT ().OnTerminal (path .MustNewComponent ("d" ))
101
102
102
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("./a////../b/c/../d" ), scopeWalker ))
103
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("./a////../b/c/../d" ), scopeWalker ))
103
104
})
104
105
105
106
t .Run ("SymlinkWithoutSlash" , func (t * testing.T ) {
@@ -108,12 +109,12 @@ func TestResolve(t *testing.T) {
108
109
scopeWalker1 .EXPECT ().OnRelative ().Return (componentWalker1 , nil )
109
110
scopeWalker2 := mock .NewMockScopeWalker (ctrl )
110
111
componentWalker1 .EXPECT ().OnTerminal (path .MustNewComponent ("a" )).
111
- Return (& path.GotSymlink {Parent : scopeWalker2 , Target : path .MustNewUNIXParser ("b" )}, nil )
112
+ Return (& path.GotSymlink {Parent : scopeWalker2 , Target : path .NewUNIXParser ("b" )}, nil )
112
113
componentWalker2 := mock .NewMockComponentWalker (ctrl )
113
114
scopeWalker2 .EXPECT ().OnRelative ().Return (componentWalker2 , nil )
114
115
componentWalker2 .EXPECT ().OnTerminal (path .MustNewComponent ("b" ))
115
116
116
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("a" ), scopeWalker1 ))
117
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("a" ), scopeWalker1 ))
117
118
})
118
119
119
120
t .Run ("SymlinkWithSlashInSymlink" , func (t * testing.T ) {
@@ -122,14 +123,14 @@ func TestResolve(t *testing.T) {
122
123
scopeWalker1 .EXPECT ().OnRelative ().Return (componentWalker1 , nil )
123
124
scopeWalker2 := mock .NewMockScopeWalker (ctrl )
124
125
componentWalker1 .EXPECT ().OnTerminal (path .MustNewComponent ("a" )).
125
- Return (& path.GotSymlink {Parent : scopeWalker2 , Target : path .MustNewUNIXParser ("b/" )}, nil )
126
+ Return (& path.GotSymlink {Parent : scopeWalker2 , Target : path .NewUNIXParser ("b/" )}, nil )
126
127
componentWalker2 := mock .NewMockComponentWalker (ctrl )
127
128
scopeWalker2 .EXPECT ().OnRelative ().Return (componentWalker2 , nil )
128
129
componentWalker3 := mock .NewMockComponentWalker (ctrl )
129
130
componentWalker2 .EXPECT ().OnDirectory (path .MustNewComponent ("b" )).
130
131
Return (path.GotDirectory {Child : componentWalker3 }, nil )
131
132
132
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("a" ), scopeWalker1 ))
133
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("a" ), scopeWalker1 ))
133
134
})
134
135
135
136
t .Run ("SymlinkWithSlashInPath" , func (t * testing.T ) {
@@ -138,14 +139,14 @@ func TestResolve(t *testing.T) {
138
139
scopeWalker1 .EXPECT ().OnRelative ().Return (componentWalker1 , nil )
139
140
scopeWalker2 := mock .NewMockScopeWalker (ctrl )
140
141
componentWalker1 .EXPECT ().OnDirectory (path .MustNewComponent ("a" )).
141
- Return (path.GotSymlink {Parent : scopeWalker2 , Target : path .MustNewUNIXParser ("b" )}, nil )
142
+ Return (path.GotSymlink {Parent : scopeWalker2 , Target : path .NewUNIXParser ("b" )}, nil )
142
143
componentWalker2 := mock .NewMockComponentWalker (ctrl )
143
144
scopeWalker2 .EXPECT ().OnRelative ().Return (componentWalker2 , nil )
144
145
componentWalker3 := mock .NewMockComponentWalker (ctrl )
145
146
componentWalker2 .EXPECT ().OnDirectory (path .MustNewComponent ("b" )).
146
147
Return (path.GotDirectory {Child : componentWalker3 }, nil )
147
148
148
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("a/" ), scopeWalker1 ))
149
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("a/" ), scopeWalker1 ))
149
150
})
150
151
151
152
t .Run ("SymlinkInSymlinkInSymlink" , func (t * testing.T ) {
@@ -154,17 +155,17 @@ func TestResolve(t *testing.T) {
154
155
scopeWalker1 .EXPECT ().OnRelative ().Return (componentWalker1 , nil )
155
156
scopeWalker2 := mock .NewMockScopeWalker (ctrl )
156
157
componentWalker1 .EXPECT ().OnTerminal (path .MustNewComponent ("a" )).
157
- Return (& path.GotSymlink {Parent : scopeWalker2 , Target : path .MustNewUNIXParser ("b/z" )}, nil )
158
+ Return (& path.GotSymlink {Parent : scopeWalker2 , Target : path .NewUNIXParser ("b/z" )}, nil )
158
159
componentWalker2 := mock .NewMockComponentWalker (ctrl )
159
160
scopeWalker2 .EXPECT ().OnRelative ().Return (componentWalker2 , nil )
160
161
scopeWalker3 := mock .NewMockScopeWalker (ctrl )
161
162
componentWalker2 .EXPECT ().OnDirectory (path .MustNewComponent ("b" )).
162
- Return (path.GotSymlink {Parent : scopeWalker3 , Target : path .MustNewUNIXParser ("c/y" )}, nil )
163
+ Return (path.GotSymlink {Parent : scopeWalker3 , Target : path .NewUNIXParser ("c/y" )}, nil )
163
164
componentWalker3 := mock .NewMockComponentWalker (ctrl )
164
165
scopeWalker3 .EXPECT ().OnRelative ().Return (componentWalker3 , nil )
165
166
scopeWalker4 := mock .NewMockScopeWalker (ctrl )
166
167
componentWalker3 .EXPECT ().OnDirectory (path .MustNewComponent ("c" )).
167
- Return (path.GotSymlink {Parent : scopeWalker4 , Target : path .MustNewUNIXParser ("x" )}, nil )
168
+ Return (path.GotSymlink {Parent : scopeWalker4 , Target : path .NewUNIXParser ("x" )}, nil )
168
169
componentWalker4 := mock .NewMockComponentWalker (ctrl )
169
170
scopeWalker4 .EXPECT ().OnRelative ().Return (componentWalker4 , nil )
170
171
componentWalker5 := mock .NewMockComponentWalker (ctrl )
@@ -175,6 +176,6 @@ func TestResolve(t *testing.T) {
175
176
Return (path.GotDirectory {Child : componentWalker6 }, nil )
176
177
componentWalker6 .EXPECT ().OnTerminal (path .MustNewComponent ("z" ))
177
178
178
- require .NoError (t , path .Resolve (path .MustNewUNIXParser ("a" ), scopeWalker1 ))
179
+ require .NoError (t , path .Resolve (path .NewUNIXParser ("a" ), scopeWalker1 ))
179
180
})
180
181
}
0 commit comments