@@ -111,8 +111,22 @@ final class DocUploadBundleTests: XCTestCase {
111
111
" main/index.html " ,
112
112
" main/index/index.json " ] {
113
113
let path = tempDir + " / " + pathComponent
114
- XCTAssertTrue ( Foundation . FileManager. default. fileExists ( atPath: path) , " does not exist: \( path) " )
114
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: path) , " does not exist: \( path) " )
115
115
}
116
+ // test roundtrip, to ensure the zip library can zip/unzip its own product
117
+ // zip
118
+ let urls = [ tempDir + " /metadata.json " ,
119
+ tempDir + " /main " ] . map ( URL . init ( fileURLWithPath: ) )
120
+ let zipped = URL ( fileURLWithPath: tempDir + " /out.zip " )
121
+ try Zipper . zip ( paths: urls, to: zipped)
122
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: zipped. path ( ) ) )
123
+ // unzip
124
+ let out = URL ( fileURLWithPath: tempDir + " /out " )
125
+ try Zipper . unzip ( from: zipped, to: out)
126
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. path ( ) ) )
127
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. appendingPathComponent ( " metadata.json " ) . path ( ) ) )
128
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. appendingPathComponent ( " main/index.html " ) . path ( ) ) )
129
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. appendingPathComponent ( " main/index/index.json " ) . path ( ) ) )
116
130
}
117
131
}
118
132
@@ -127,8 +141,22 @@ final class DocUploadBundleTests: XCTestCase {
127
141
" 1b9fc8fc0d7177b39d5f60ba86f70295b56d0589/index.html " ,
128
142
" 1b9fc8fc0d7177b39d5f60ba86f70295b56d0589/index/index.json " ] {
129
143
let path = tempDir + " / " + pathComponent
130
- XCTAssertTrue ( Foundation . FileManager. default. fileExists ( atPath: path) , " does not exist: \( path) " )
144
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: path) , " does not exist: \( path) " )
131
145
}
146
+ // test roundtrip, to ensure the zip library can zip/unzip its own product
147
+ // zip
148
+ let urls = [ tempDir + " /metadata.json " ,
149
+ tempDir + " /1b9fc8fc0d7177b39d5f60ba86f70295b56d0589 " ] . map ( URL . init ( fileURLWithPath: ) )
150
+ let zipped = URL ( fileURLWithPath: tempDir + " /out.zip " )
151
+ try Zipper . zip ( paths: urls, to: zipped)
152
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: zipped. path ( ) ) )
153
+ // unzip
154
+ let out = URL ( fileURLWithPath: tempDir + " /out " )
155
+ try Zipper . unzip ( from: zipped, to: out)
156
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. path ( ) ) )
157
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. appendingPathComponent ( " metadata.json " ) . path ( ) ) )
158
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. appendingPathComponent ( " 1b9fc8fc0d7177b39d5f60ba86f70295b56d0589/index.html " ) . path ( ) ) )
159
+ XCTAssertTrue ( FileManager . default. fileExists ( atPath: out. appendingPathComponent ( " 1b9fc8fc0d7177b39d5f60ba86f70295b56d0589/index/index.json " ) . path ( ) ) )
132
160
}
133
161
}
134
162
0 commit comments