From eef6fa3e8496ca0debd1619392167d8888e32b0a Mon Sep 17 00:00:00 2001 From: Francesco Paolo Severino Date: Mon, 26 Aug 2024 13:40:54 +0200 Subject: [PATCH] Add more test coverage --- Tests/ZipTests/ZipTests.swift | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Tests/ZipTests/ZipTests.swift b/Tests/ZipTests/ZipTests.swift index 68037671..3e8f9f9e 100644 --- a/Tests/ZipTests/ZipTests.swift +++ b/Tests/ZipTests/ZipTests.swift @@ -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(