Files
Sparkle/Tests/SUInstallerTest.m
Kornel Lesiński 2d30762570 Merge remote-tracking branch 'origin/master' into ui-separation-and-xpc
* origin/master: (39 commits)
  %s is deliberate in this format string
  Unused
  Make generate_appcast available as a shared scheme
  Shush Xcode
  Link straight to docs from the readme
  ignore .html files when scanning for archives
  Missing strings translation.
  Updated swift
  Warn against abusing installUpdatesIfAvailable
  when generating the appcast, if an .html file exists of the same name as the archive, then it will be linked in as the releaseNotesLink
  Revert "Fix pt_BR translations"
  Revert "Fix pt_BR translations (#1039)"
  Fix Japanse localization
  Add more info to auth tool run failure
  Fix pt_BR translations (#1039)
  Fix pt_BR translations
  Disable the keyboard shortcut for the install button for scheduled updates to avoid accidental installs.
  added `sparkle:shortVersionString` to the enclosure, #1032
  Changelog
  percent encode the filename used in the delta url
  ...
2017-03-24 12:14:05 +00:00

83 lines
2.3 KiB
Objective-C

//
// SUInstallerTest.m
// Sparkle
//
// Created by Kornel on 24/04/2015.
// Copyright (c) 2015 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#import "SUHost.h"
#import "SUInstaller.h"
#import "SUInstallerProtocol.h"
#import "SPUInstallationType.h"
#import <unistd.h>
@interface SUInstallerTest : XCTestCase
@end
@implementation SUInstallerTest
- (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
#if __clang_major__ >= 6
- (void)testInstallIfRoot
{
uid_t uid = getuid();
if (uid) {
NSLog(@"Test must be run as root: sudo xctest -XCTest SUInstallerTest 'Sparkle Unit Tests.xctest'");
return;
}
NSString *expectedDestination = @"/tmp/sparklepkgtest.app";
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:expectedDestination error:nil];
XCTAssertFalse([fm fileExistsAtPath:expectedDestination isDirectory:nil]);
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@"test" ofType:@"pkg"];
XCTAssertNotNil(path);
SUHost *host = [[SUHost alloc] initWithBundle:bundle];
NSError *installerError = nil;
id<SUInstallerProtocol> installer = [SUInstaller installerForHost:host expectedInstallationType:SPUInstallationTypeGuidedPackage updateDirectory:[path stringByDeletingLastPathComponent] error:&installerError];
if (installer == nil) {
XCTFail(@"Installer is nil with error: %@", installerError);
return;
}
NSError *initialInstallError = nil;
if (![installer performInitialInstallation:&initialInstallError]) {
XCTFail(@"Initial Installation failed with error: %@", initialInstallError);
return;
}
NSError *finalInstallError = nil;
if (![installer performFinalInstallationProgressBlock:nil error:&finalInstallError]) {
XCTFail(@"Final installation failed with error: %@", finalInstallError);
return;
}
XCTAssertTrue([fm fileExistsAtPath:expectedDestination isDirectory:nil]);
[fm removeItemAtPath:expectedDestination error:nil];
}
#endif
@end