@@ -301,6 +301,18 @@ func testArchive(t *testing.T, context spec.G, it spec.S) {
301
301
_ , err = f .Write ([]byte ("some-file" ))
302
302
Expect (err ).NotTo (HaveOccurred ())
303
303
304
+ _ , err = zw .Create ("some-dir/" )
305
+ Expect (err ).NotTo (HaveOccurred ())
306
+
307
+ header = & zip.FileHeader {Name : filepath .Join ("some-dir" , "some-nested-file" )}
308
+ header .SetMode (0644 )
309
+
310
+ f , err = zw .CreateHeader (header )
311
+ Expect (err ).NotTo (HaveOccurred ())
312
+
313
+ _ , err = f .Write ([]byte ("nested file" ))
314
+ Expect (err ).NotTo (HaveOccurred ())
315
+
304
316
Expect (zw .Close ()).To (Succeed ())
305
317
306
318
archive = vacation .NewArchive (buffer )
@@ -318,6 +330,18 @@ func testArchive(t *testing.T, context spec.G, it spec.S) {
318
330
Expect (err ).NotTo (HaveOccurred ())
319
331
Expect (files ).To (ConsistOf ([]string {
320
332
filepath .Join (tempDir , "some-file" ),
333
+ filepath .Join (tempDir , "some-dir" ),
334
+ }))
335
+ })
336
+
337
+ it ("unpackages the archive into the path but also strips the first component" , func () {
338
+ err := archive .StripComponents (1 ).Decompress (tempDir )
339
+ Expect (err ).NotTo (HaveOccurred ())
340
+
341
+ files , err := filepath .Glob (filepath .Join (tempDir , "*" ))
342
+ Expect (err ).NotTo (HaveOccurred ())
343
+ Expect (files ).To (ConsistOf ([]string {
344
+ filepath .Join (tempDir , "some-nested-file" ),
321
345
}))
322
346
})
323
347
})
0 commit comments