mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Fix unit tests
This commit is contained in:
1 parent
ab294d607d
commit
477d0a243f
6 files changed
+31
-26
No files matched your search
Vendored
+1
-1
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUAppcast (Private)
|
||||
|
||||
- (nullable instancetype)initWithXMLData:(NSData *)xmlData relativeToURL:(NSURL *)relativeURL error:(NSError * __autoreleasing *)error;
|
||||
- (nullable instancetype)initWithXMLData:(NSData *)xmlData relativeToURL:(NSURL * _Nullable)relativeURL error:(NSError * __autoreleasing *)error;
|
||||
|
||||
- (SUAppcast *)copyByFilteringItems:(BOOL (^)(SUAppcastItem *))filterBlock;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@class SUAppcastItem;
|
||||
SU_EXPORT @interface SUAppcast : NSObject
|
||||
|
||||
@property (readonly, copy, nullable) NSArray<SUAppcastItem *> *items;
|
||||
@property (readonly, copy) NSArray<SUAppcastItem *> *items;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -30,7 +30,7 @@
|
||||
|
||||
@synthesize items = _items;
|
||||
|
||||
- (nullable instancetype)initWithXMLData:(NSData *)xmlData relativeToURL:(NSURL *)relativeURL error:(NSError * __autoreleasing *)error
|
||||
- (nullable instancetype)initWithXMLData:(NSData *)xmlData relativeToURL:(NSURL * _Nullable)relativeURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -72,7 +72,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(NSArray *)parseAppcastItemsFromXMLData:(NSData *)appcastData relativeToURL:(NSURL *)appcastURL error:(NSError *__autoreleasing*)errorp {
|
||||
-(NSArray *)parseAppcastItemsFromXMLData:(NSData *)appcastData relativeToURL:(NSURL * _Nullable)appcastURL error:(NSError *__autoreleasing*)errorp {
|
||||
if (errorp) {
|
||||
*errorp = nil;
|
||||
}
|
||||
|
||||
Vendored
+12
-3
@@ -204,7 +204,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
return [self initWithDictionary:dict relativeToURL:nil failureReason:error];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL *)appcastURL failureReason:(NSString *__autoreleasing *)error
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString *__autoreleasing *)error
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
@@ -284,7 +284,11 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
if (enclosureURLString) {
|
||||
// Sparkle used to always URL-encode, so for backwards compatibility spaces in URLs must be forgiven.
|
||||
NSString *fileURLString = [enclosureURLString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
|
||||
_fileURL = [NSURL URLWithString:fileURLString relativeToURL:appcastURL];
|
||||
if (appcastURL != nil) {
|
||||
_fileURL = [NSURL URLWithString:fileURLString relativeToURL:appcastURL];
|
||||
} else {
|
||||
_fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
}
|
||||
if (enclosure) {
|
||||
_signatures = [[SUSignatures alloc] initWithDsa:[enclosure objectForKey:SUAppcastAttributeDSASignature] ed:[enclosure objectForKey:SUAppcastAttributeEDSignature]];
|
||||
@@ -334,7 +338,12 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
if (releaseNotesString) {
|
||||
NSURL *url = [NSURL URLWithString:releaseNotesString relativeToURL:appcastURL];
|
||||
NSURL *url;
|
||||
if (appcastURL != nil) {
|
||||
url = [NSURL URLWithString:releaseNotesString relativeToURL:appcastURL];
|
||||
} else {
|
||||
url = [NSURL URLWithString:releaseNotesString];
|
||||
}
|
||||
if ([url isFileURL]) {
|
||||
SULog(SULogLevelError, @"Release notes with file:// URLs are not supported");
|
||||
} else {
|
||||
|
||||
+14
-12
@@ -12,12 +12,13 @@ import Sparkle
|
||||
class SUAppcastTest: XCTestCase {
|
||||
|
||||
func testParseAppcast() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!
|
||||
let testData = NSData(contentsOfFile: testFile)!
|
||||
|
||||
let testURL = Bundle(for: SUAppcastTest.self).url(forResource: "testappcast", withExtension: "xml")!
|
||||
|
||||
do {
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data, relativeTo: nil) as! [SUAppcastItem]
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData, relativeTo: nil)
|
||||
let items = appcast.items
|
||||
|
||||
XCTAssertEqual(4, items.count)
|
||||
|
||||
@@ -46,7 +47,7 @@ class SUAppcastTest: XCTestCase {
|
||||
// Test best appcast item & a delta update item
|
||||
let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil)
|
||||
|
||||
let supportedAppcastItems = supportedAppcast.items!
|
||||
let supportedAppcastItems = supportedAppcast.items
|
||||
|
||||
var deltaItem: SUAppcastItem?
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcastItems, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator())
|
||||
@@ -72,7 +73,6 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
|
||||
func testParseAppcastWithLocalizedReleaseNotes() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testlocalizedreleasenotesappcast",
|
||||
ofType: "xml")!
|
||||
let testFileUrl = URL(fileURLWithPath: testFile)
|
||||
@@ -80,7 +80,8 @@ class SUAppcastTest: XCTestCase {
|
||||
|
||||
do {
|
||||
let testFileData = try Data(contentsOf: testFileUrl)
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testFileData, relativeTo: testFileUrl) as! [SUAppcastItem];
|
||||
let appcast = try SUAppcast(xmlData: testFileData, relativeTo: testFileUrl)
|
||||
let items = appcast.items
|
||||
XCTAssertEqual("https://sparkle-project.org/#localized_notes_link_works", items[0].releaseNotesURL.absoluteString)
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
@@ -89,12 +90,12 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
|
||||
func testNamespaces() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!
|
||||
let testData = NSData(contentsOfFile: testFile)!
|
||||
|
||||
do {
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data, relativeTo: nil) as! [SUAppcastItem]
|
||||
let appcast = try SUAppcast(xmlData: testData as Data, relativeTo: nil)
|
||||
let items = appcast.items
|
||||
|
||||
XCTAssertEqual(2, items.count)
|
||||
|
||||
@@ -109,13 +110,14 @@ class SUAppcastTest: XCTestCase {
|
||||
}
|
||||
|
||||
func testRelativeURLs() {
|
||||
let appcast = SUAppcast()
|
||||
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "test-relative-urls", ofType: "xml")!
|
||||
let testData = NSData(contentsOfFile: testFile)!
|
||||
|
||||
do {
|
||||
let baseURL = URL(string: "https://fake.sparkle-project.org/updates/index.xml")!
|
||||
let items = try appcast.parseAppcastItems(fromXMLData: testData as Data, relativeTo: baseURL) as! [SUAppcastItem]
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData as Data, relativeTo: baseURL)
|
||||
let items = appcast.items
|
||||
|
||||
XCTAssertEqual(2, items.count)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "SUFileManager.h"
|
||||
#import "SUExport.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcast+Private.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUAppcastDriver.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
@@ -41,13 +42,6 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine";
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface SUAppcast (Private)
|
||||
|
||||
-(nullable NSArray *)parseAppcastItemsFromXMLData:(NSData *)appcastData relativeToURL:(nullable NSURL *)appcastURL error:(NSError *__autoreleasing*)errorp;
|
||||
|
||||
@end
|
||||
|
||||
@interface SUBinaryDeltaUnarchiver (Private)
|
||||
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath;
|
||||
|
||||
Reference in new issue
Block a user