Skip to content

Commit

Permalink
Update unit tests to Swift 3
Browse files Browse the repository at this point in the history
  • Loading branch information
zorgiepoo committed Sep 15, 2016
1 parent 3a5c620 commit ed5dca3
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 235 deletions.
8 changes: 8 additions & 0 deletions Sparkle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1465,13 +1465,15 @@
ORGANIZATIONNAME = "Sparkle Project";
TargetAttributes = {
612279D80DB5470200AB99EA = {
LastSwiftMigration = 0800;
TestTargetID = 8DC2EF4F0486A6940098B216;
};
722954B31D04ADAF00ECF9CA = {
CreatedOnToolsVersion = 7.3.1;
};
726B2B5C1C645FC900388755 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
TestTargetID = 61B5F90109C4CEE200B25A18;
};
};
Expand Down Expand Up @@ -2162,6 +2164,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */;
buildSettings = {
SWIFT_VERSION = 3.0;
};
name = Coverage;
};
Expand Down Expand Up @@ -2257,13 +2260,15 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA3AAF3A1050B273004B3130 /* ConfigUnitTestDebug.xcconfig */;
buildSettings = {
SWIFT_VERSION = 3.0;
};
name = Debug;
};
612279DC0DB5470300AB99EA /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA3AAF391050B273004B3130 /* ConfigUnitTestRelease.xcconfig */;
buildSettings = {
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down Expand Up @@ -2315,6 +2320,7 @@
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -2325,6 +2331,7 @@
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Coverage;
};
Expand All @@ -2334,6 +2341,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
18 changes: 9 additions & 9 deletions Tests/SUAppcastTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class SUAppcastTest: XCTestCase {

func testParseAppcast() {
let appcast = SUAppcast();
let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testappcast", ofType: "xml")!;
let testFileUrl = NSURL(fileURLWithPath: testFile);
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!;
let testFileUrl = URL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);

do {
let items = try appcast.parseAppcastItemsFromXMLFile(testFileUrl) as! [SUAppcastItem];
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];

XCTAssertEqual(4, items.count);

Expand All @@ -41,20 +41,20 @@ class SUAppcastTest: XCTestCase {

// Test best appcast item & a delta update item
var deltaItem: SUAppcastItem? = nil
let bestAppcastItem = SUBasicUpdateDriver.bestItemFromAppcastItems(items, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator.defaultComparator())
let bestAppcastItem = SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator.default())

XCTAssertEqual(bestAppcastItem, items[1])
XCTAssertEqual(deltaItem!.fileURL.lastPathComponent, "3.0_from_1.0.patch")

// Test latest delta update item available
var latestDeltaItem: SUAppcastItem? = nil
SUBasicUpdateDriver.bestItemFromAppcastItems(items, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator.defaultComparator())
SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator.default())

XCTAssertEqual(latestDeltaItem!.fileURL.lastPathComponent, "3.0_from_2.0.patch")

// Test a delta item that does not exist
var nonexistantDeltaItem: SUAppcastItem? = nil
SUBasicUpdateDriver.bestItemFromAppcastItems(items, getDeltaItem: &nonexistantDeltaItem, withHostVersion: "2.1", comparator: SUStandardVersionComparator.defaultComparator())
SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &nonexistantDeltaItem, withHostVersion: "2.1", comparator: SUStandardVersionComparator.default())

XCTAssertNil(nonexistantDeltaItem)
} catch let err as NSError {
Expand All @@ -65,12 +65,12 @@ class SUAppcastTest: XCTestCase {

func testNamespaces() {
let appcast = SUAppcast();
let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testnamespaces", ofType: "xml")!;
let testFileUrl = NSURL(fileURLWithPath: testFile);
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!;
let testFileUrl = URL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);

do {
let items = try appcast.parseAppcastItemsFromXMLFile(testFileUrl) as! [SUAppcastItem];
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];

XCTAssertEqual(2, items.count);

Expand Down
Loading

0 comments on commit ed5dca3

Please sign in to comment.