Skip to content

Commit

Permalink
Add more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Aug 26, 2024
1 parent 089084f commit eef6fa3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Tests/ZipTests/ZipTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,32 @@ final class ZipTests: XCTestCase {
XCTAssertEqual(ZipCompression.BestCompression.minizipCompression, 9)
}

func testInit() {
var zip: Zip? = Zip()
XCTAssertNotNil(zip)
zip = nil
XCTAssertNil(zip)
}

// Tests if https://github.com/vapor-community/Zip/issues/4 does not occur anymore.
func testRoundTripping() throws {
// "prod-apple-swift-metrics-main-e6a00d36.zip" is the original zip file from the issue.

// "prod-apple-swift-metrics-main-e6a00d36-test.zip" is a zip file
// that was created by unzipping the original zip file with Finder on macOS 14.6.1
// and then zipping it again using vapor-community/Zip v2.2.0.
let zipFilePath = url(forResource: "prod-apple-swift-metrics-main-e6a00d36", withExtension: "zip")!
let failDestinationPath = try autoRemovingSandbox()
XCTAssertThrowsError(try Zip.unzipFile(zipFilePath, destination: failDestinationPath, overwrite: true))

// "prod-apple-swift-metrics-main-e6a00d36-finder.zip" is a zip file
// that was created by unzipping the original zip file with Finder on macOS 14.6.1
// and then zipping it again using Finder on macOS 14.6.1.

let zipFilePath = url(forResource: "prod-apple-swift-metrics-main-e6a00d36-test", withExtension: "zip")!
// "prod-apple-swift-metrics-main-e6a00d36-test.zip" is a zip file
// that was created by unzipping the original zip file with Finder on macOS 14.6.1
// and then zipping it again using vapor-community/Zip v2.2.0.

let testZipFilePath = url(forResource: "prod-apple-swift-metrics-main-e6a00d36-test", withExtension: "zip")!
let destinationPath = try autoRemovingSandbox()
XCTAssertNoThrow(try Zip.unzipFile(zipFilePath, destination: destinationPath, overwrite: true))
XCTAssertNoThrow(try Zip.unzipFile(testZipFilePath, destination: destinationPath, overwrite: true))

let destinationFolder = destinationPath.appendingPathComponent("prod-apple-swift-metrics-main-e6a00d36")
XCTAssertTrue(
Expand Down

0 comments on commit eef6fa3

Please sign in to comment.