Merge pull request #780 from zorgiepoo/fix-tests

Fix issues with unit tests
This commit is contained in:
Kornel committed 2016-04-19 10:11:35 +01:00
commit 7a9ff3de48
3 files changed
+27 -12

No files matched your search

+20 -11
View File
@@ -10,6 +10,7 @@
#import <XCTest/XCTest.h>
#import "NTSynchronousTask.h"
#import "SUCodeSigningVerifier.h"
#import "SUFileManager.h"
@interface SUCodeSigningVerifierTest : XCTestCase
@@ -32,11 +33,24 @@
NSBundle *unitTestBundle = [NSBundle bundleForClass:[self class]];
NSString *unitTestBundleIdentifier = unitTestBundle.bundleIdentifier;
NSString *zippedAppPath = [unitTestBundle pathForResource:@"SparkleTestCodeSignApp" ofType:@"zip"];
NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:unitTestBundleIdentifier];
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO];
NSError *tempError = nil;
NSURL *tempDir = [fileManager makeTemporaryDirectoryWithPreferredName:unitTestBundleIdentifier appropriateForDirectoryURL:[NSURL fileURLWithPath:zippedAppPath] error:&tempError];
if (tempDir == nil) {
XCTFail(@"Failed to create temporary directory with error: %@", tempError);
return;
}
NSString *tempDirPath = tempDir.path;
XCTAssertNotNil(tempDirPath);
NSError *error = nil;
if ([[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:&error]) {
if ([self unzip:zippedAppPath toPath:tempDir]) {
self.notSignedAppPath = [tempDir stringByAppendingPathComponent:@"SparkleTestCodeSignApp.app"];
if ([[NSFileManager defaultManager] createDirectoryAtPath:tempDirPath withIntermediateDirectories:YES attributes:nil error:&error]) {
if ([self unzip:zippedAppPath toPath:tempDirPath]) {
self.notSignedAppPath = [tempDirPath stringByAppendingPathComponent:@"SparkleTestCodeSignApp.app"];
[self setupValidSignedApp];
[self setupInvalidSignedApp];
}
@@ -54,13 +68,8 @@
[super tearDown];
if (self.notSignedAppPath) {
[[NSFileManager defaultManager] removeItemAtPath:self.notSignedAppPath error:nil];
}
if (self.validSignedAppPath) {
[[NSFileManager defaultManager] removeItemAtPath:self.validSignedAppPath error:nil];
}
if (self.invalidSignedAppPath) {
[[NSFileManager defaultManager] removeItemAtPath:self.invalidSignedAppPath error:nil];
NSString *tempDir = [self.notSignedAppPath stringByDeletingLastPathComponent];
[[NSFileManager defaultManager] removeItemAtPath:tempDir error:nil];
}
}
+1 -1
View File
@@ -24,7 +24,7 @@
{
[super setUp];
self.queue = [[NSOperationQueue alloc] init];
self.updater = [[SUUpdater alloc] init];
self.updater = [[SUUpdater alloc] initForBundle:[NSBundle bundleForClass:[self class]]];
self.updater.delegate = self;
}
+6
View File
@@ -16,5 +16,11 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>SUEnableAutomaticChecks</key>
<true/>
<key>SUEnableSystemProfiling</key>
<false/>
<key>SUPublicDSAKeyFile</key>
<string>test-pubkey.pem</string>
</dict>
</plist>