@@ -27,6 +27,7 @@ func TestOpen(t *testing.T) {
27
27
28
28
tests := []struct {
29
29
name string
30
+ dir string
30
31
want []byte
31
32
wantErr bool
32
33
}{
@@ -38,6 +39,16 @@ func TestOpen(t *testing.T) {
38
39
name : "testdata/empty2.txt" ,
39
40
want : []byte ("test" ),
40
41
},
42
+ {
43
+ name : "empty.txt" ,
44
+ dir : "testdata" ,
45
+ want : []byte ("" ),
46
+ },
47
+ {
48
+ name : "empty2.txt" ,
49
+ dir : "testdata" ,
50
+ want : []byte ("test" ),
51
+ },
41
52
{
42
53
name : "non-existent" ,
43
54
wantErr : true ,
@@ -49,7 +60,7 @@ func TestOpen(t *testing.T) {
49
60
t .Run (tc .name , func (t * testing.T ) {
50
61
t .Parallel ()
51
62
52
- fs := embedfs .New (& testdataDir )
63
+ fs := embedfs .New (& testdataDir , tc . dir )
53
64
54
65
var got []byte
55
66
f , err := fs .Open (tc .name )
@@ -123,7 +134,7 @@ func TestOpenFileFlags(t *testing.T) {
123
134
t .Run (tc .name , func (t * testing.T ) {
124
135
t .Parallel ()
125
136
126
- fs := embedfs .New (& testdataDir )
137
+ fs := embedfs .New (& testdataDir , "" )
127
138
128
139
_ , err := fs .OpenFile (tc .file , tc .flag , 0o700 )
129
140
if tc .wantErr != "" {
@@ -140,6 +151,7 @@ func TestStat(t *testing.T) {
140
151
141
152
tests := []struct {
142
153
name string
154
+ dir string
143
155
want string
144
156
isDir bool
145
157
wantErr bool
@@ -152,6 +164,16 @@ func TestStat(t *testing.T) {
152
164
name : "testdata/empty2.txt" ,
153
165
want : "empty2.txt" ,
154
166
},
167
+ {
168
+ name : "empty.txt" ,
169
+ dir : "testdata" ,
170
+ want : "empty.txt" ,
171
+ },
172
+ {
173
+ name : "empty2.txt" ,
174
+ dir : "testdata" ,
175
+ want : "empty2.txt" ,
176
+ },
155
177
{
156
178
name : "non-existent" ,
157
179
wantErr : true ,
@@ -168,7 +190,7 @@ func TestStat(t *testing.T) {
168
190
t .Run (tc .name , func (t * testing.T ) {
169
191
t .Parallel ()
170
192
171
- fs := embedfs .New (& testdataDir )
193
+ fs := embedfs .New (& testdataDir , tc . dir )
172
194
173
195
fi , err := fs .Stat (tc .name )
174
196
if tc .wantErr {
@@ -227,7 +249,7 @@ func TestReadDir(t *testing.T) {
227
249
t .Run (tc .name , func (t * testing.T ) {
228
250
t .Parallel ()
229
251
230
- fs := embedfs .New (tc .fs )
252
+ fs := embedfs .New (tc .fs , "" )
231
253
232
254
fis , err := fs .ReadDir (tc .path )
233
255
if tc .wantErr {
@@ -255,7 +277,7 @@ func TestReadDir(t *testing.T) {
255
277
func TestUnsupported (t * testing.T ) {
256
278
t .Parallel ()
257
279
258
- fs := embedfs .New (& testdataDir )
280
+ fs := embedfs .New (& testdataDir , "" )
259
281
260
282
_ , err := fs .Create ("test" )
261
283
require .ErrorIs (t , err , billy .ErrReadOnly )
@@ -273,7 +295,7 @@ func TestUnsupported(t *testing.T) {
273
295
func TestFileUnsupported (t * testing.T ) {
274
296
t .Parallel ()
275
297
276
- fs := embedfs .New (& testdataDir )
298
+ fs := embedfs .New (& testdataDir , "" )
277
299
278
300
f , err := fs .Open ("testdata/empty.txt" )
279
301
require .NoError (t , err )
@@ -288,7 +310,7 @@ func TestFileUnsupported(t *testing.T) {
288
310
289
311
//nolint:paralleltest
290
312
func TestFileSeek (t * testing.T ) {
291
- fs := embedfs .New (& testdataDir )
313
+ fs := embedfs .New (& testdataDir , "" )
292
314
293
315
f , err := fs .Open ("testdata/empty2.txt" )
294
316
require .NoError (t , err )
@@ -359,7 +381,7 @@ func TestJoin(t *testing.T) {
359
381
t .Run (tc .name , func (t * testing.T ) {
360
382
t .Parallel ()
361
383
362
- fs := embedfs .New (& empty )
384
+ fs := embedfs .New (& empty , "" )
363
385
364
386
got := fs .Join (tc .path ... )
365
387
assert .Equal (t , tc .want , got )
0 commit comments