Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jwelton committed Nov 25, 2016
1 parent bfb8200 commit cb5c7a4
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions ZipTests/ZipTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,18 @@ class ZipTests: XCTestCase {
func testCancelDuringZipCancels() {
var currentProgress: Double = 0

let expectation = expectationWithDescription("Zip operation should throw .OperationCancelled")
let expect = expectation(description: "Zip operation should throw .OperationCancelled")

do {
let progress = NSProgress()
let progress = Progress()
progress.totalUnitCount = 1

let imageURL1 = NSBundle(forClass: ZipTests.self).URLForResource("3crBXeO", withExtension: "gif")!
let imageURL2 = NSBundle(forClass: ZipTests.self).URLForResource("kYkLkPf", withExtension: "gif")!
let documentsFolder = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let zipFilePath = documentsFolder.URLByAppendingPathComponent("archive.zip")
let imageURL1 = Bundle(for: ZipTests.self).url(forResource: "3crBXeO", withExtension: "gif")!
let imageURL2 = Bundle(for: ZipTests.self).url(forResource: "kYkLkPf", withExtension: "gif")!
let documentsFolder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] as NSURL
let zipFilePath = documentsFolder.appendingPathComponent("archive.zip")!

try Zip.zipFiles([imageURL1, imageURL2], zipFilePath: zipFilePath, password: nil) { progress in
try Zip.zipFiles(paths: [imageURL1, imageURL2], zipFilePath: zipFilePath, password: nil) { progress in
currentProgress = progress

if progress > 0 {
Expand All @@ -298,27 +298,27 @@ class ZipTests: XCTestCase {

}
catch {
XCTAssertEqual(error as? ZipError, .OperationCancelled)
XCTAssertEqual(error as? ZipError, .operationCancelled)
XCTAssertLessThan(currentProgress, 1, "Progress should be less than 1 when cancelling the current operation")
expectation.fulfill()
expect.fulfill()
}

waitForExpectationsWithTimeout(5) { error in
waitForExpectations(timeout: 5) { error in
XCTAssertNil(error)
}
}

func testCancelDuringUnzipCancels() {
var currentProgress: Double = 0
let expectation = expectationWithDescription("Unzip operation should throw .OperationCancelled")
let expect = expectation(description: "Unzip operation should throw .OperationCancelled")

do {
let progress = NSProgress()
let progress = Progress()
progress.totalUnitCount = 1

let bookURL = NSBundle(forClass: ZipTests.self).URLForResource("bb8", withExtension: "zip")!
let documentsFolder = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let zipFilePath = documentsFolder.URLByAppendingPathComponent("contents")
let bookURL = Bundle(for: ZipTests.self).url(forResource: "bb8", withExtension: "zip")!
let documentsFolder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] as NSURL
let zipFilePath = documentsFolder.appendingPathComponent("contents")!

try Zip.unzipFile(bookURL, destination: zipFilePath, overwrite: true, password: nil) { progress in
currentProgress = progress
Expand All @@ -329,12 +329,12 @@ class ZipTests: XCTestCase {
}
}
catch {
XCTAssertEqual(error as? ZipError, .OperationCancelled)
XCTAssertEqual(error as? ZipError, .operationCancelled)
XCTAssertLessThan(currentProgress, 1, "Progress should be less than 1 when cancelling the current operation")
expectation.fulfill()
expect.fulfill()
}

waitForExpectationsWithTimeout(5) { error in
waitForExpectations(timeout: 5) { error in
XCTAssertNil(error)
}
}
Expand Down

0 comments on commit cb5c7a4

Please sign in to comment.