mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Add unit tests for critical updates
This commit is contained in:
1 parent
8f488c6ffd
commit
8fb44df0b7
2 files changed
+43
-1
No files matched your search
@@ -13,6 +13,8 @@
|
||||
<item>
|
||||
<title>Version 3.0</title>
|
||||
<sparkle:phasedRolloutInterval>86400</sparkle:phasedRolloutInterval>
|
||||
<!-- Test legacy critical update tag -->
|
||||
<sparkle:tags><sparkle:criticalUpdate /></sparkle:tags>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="3.0" length="1346234" />
|
||||
<sparkle:deltas>
|
||||
<enclosure url="http://localhost:1337/3.0_from_2.0.patch"
|
||||
|
||||
@@ -35,7 +35,7 @@ class SUAppcastTest: XCTestCase {
|
||||
XCTAssertEqual("Version 3.0", items[1].title)
|
||||
XCTAssertNil(items[1].itemDescription)
|
||||
XCTAssertNil(items[1].dateString)
|
||||
XCTAssertFalse(items[1].isCriticalUpdate)
|
||||
XCTAssertTrue(items[1].isCriticalUpdate)
|
||||
XCTAssertEqual(items[1].phasedRolloutInterval, 86400)
|
||||
|
||||
XCTAssertEqual("Version 4.0", items[2].title)
|
||||
@@ -76,6 +76,46 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testCriticalUpdateVersion() {
|
||||
let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast", withExtension: "xml")!
|
||||
|
||||
do {
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let versionComparator = SUStandardVersionComparator.default()
|
||||
|
||||
// If critical update version is 1.5 and host version is 1.0, update should be marked critical
|
||||
do {
|
||||
let hostVersion = "1.0"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
XCTAssertTrue(appcast.items[0].isCriticalUpdate)
|
||||
}
|
||||
|
||||
// If critical update version is 1.5 and host version is 1.5, update should not be marked critical
|
||||
do {
|
||||
let hostVersion = "1.5"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
XCTAssertFalse(appcast.items[0].isCriticalUpdate)
|
||||
}
|
||||
|
||||
// If critical update version is 1.5 and host version is 1.6, update should not be marked critical
|
||||
do {
|
||||
let hostVersion = "1.6"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil, stateResolver: stateResolver)
|
||||
XCTAssertFalse(appcast.items[0].isCriticalUpdate)
|
||||
}
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
func testMinimumAutoupdateVersion() {
|
||||
let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast_minimumAutoupdateVersion", withExtension: "xml")!
|
||||
|
||||
|
||||
Reference in new issue
Block a user