Skip to content

Commit dc4ba4b

Browse files
committed
Extend test to show round-tripping fails
1 parent 1544443 commit dc4ba4b

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

Tests/DocUploadBundleTests/DocUploadBundleTests.swift

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,22 @@ final class DocUploadBundleTests: XCTestCase {
111111
"main/index.html",
112112
"main/index/index.json"] {
113113
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)")
115115
}
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()))
116130
}
117131
}
118132

@@ -127,8 +141,22 @@ final class DocUploadBundleTests: XCTestCase {
127141
"1b9fc8fc0d7177b39d5f60ba86f70295b56d0589/index.html",
128142
"1b9fc8fc0d7177b39d5f60ba86f70295b56d0589/index/index.json"] {
129143
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)")
131145
}
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()))
132160
}
133161
}
134162

0 commit comments

Comments
 (0)