@@ -22,13 +22,23 @@ final class ZipTests: XCTestCase {
22
22
func test_zip( ) async throws {
23
23
// Test basic zip behaviour we expect from the library we use
24
24
try await withTempDir { tempDir in
25
+ // temp
25
26
let tempURL = URL ( fileURLWithPath: tempDir)
27
+
28
+ // temp/a.txt
26
29
let fileA = tempURL. appendingPathComponent ( " a.txt " )
27
- let fileB = tempURL. appendingPathComponent ( " b.txt " )
28
30
try " a " . write ( to: fileA, atomically: true , encoding: . utf8)
31
+
32
+ // temp/subdir/
33
+ let subdir = tempURL. appendingPathComponent ( " subdir " )
34
+ try FileManager . default. createDirectory ( at: subdir, withIntermediateDirectories: false )
35
+
36
+ // temp/subdir/b.txt
37
+ let fileB = subdir. appendingPathComponent ( " b.txt " )
29
38
try " b " . write ( to: fileB, atomically: true , encoding: . utf8)
39
+
30
40
let zipFile = tempURL. appendingPathComponent ( " out.zip " )
31
- try Zipper . zip ( paths: [ fileA, fileB ] , to: zipFile)
41
+ try Zipper . zip ( paths: [ fileA, subdir ] , to: zipFile)
32
42
XCTAssert ( FileManager . default. fileExists ( atPath: zipFile. path) )
33
43
}
34
44
}
@@ -41,8 +51,11 @@ final class ZipTests: XCTestCase {
41
51
let outDir = tempURL. appendingPathComponent ( " out " )
42
52
try Zipper . unzip ( from: zipFile, to: outDir)
43
53
XCTAssert ( FileManager . default. fileExists ( atPath: outDir. path) )
54
+
55
+ // out/a.txt
56
+ // out/subdir/b.txt
44
57
let fileA = outDir. appendingPathComponent ( " a.txt " )
45
- let fileB = outDir. appendingPathComponent ( " b.txt " )
58
+ let fileB = outDir. appendingPathComponent ( " subdir " ) . appendingPathComponent ( " b.txt " )
46
59
XCTAssert ( FileManager . default. fileExists ( atPath: fileA. path) )
47
60
XCTAssert ( FileManager . default. fileExists ( atPath: fileB. path) )
48
61
XCTAssertEqual ( try String ( contentsOf: fileA) , " a " )
0 commit comments