add tests

This commit is contained in:
Geoffrey Goh
2015-12-18 00:08:11 -08:00
parent 61f83fde0d
commit bc52e8f0c5
58 changed files with 58127 additions and 1074 deletions

View File

@@ -14,7 +14,12 @@ NSString * const UnzippedFolderName = @"unzipped";
+ (NSString *)getCodePushPath
{
return [[CodePush getApplicationSupportDirectory] stringByAppendingPathComponent:@"CodePush"];
NSString* codePushPath = [[CodePush getApplicationSupportDirectory] stringByAppendingPathComponent:@"CodePush"];
if ([CodePush isUsingTestConfiguration]) {
codePushPath = [codePushPath stringByAppendingPathComponent:@"TestPackages"];
}
return codePushPath;
}
+ (NSString *)getDownloadFilePath
@@ -481,4 +486,31 @@ NSString * const UnzippedFolderName = @"unzipped";
[self updateCurrentPackageInfo:info error:&error];
}
+ (void)downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl
{
NSURL *urlRequest = [NSURL URLWithString:remoteBundleUrl];
NSError *error = nil;
NSString *downloadedBundle = [NSString stringWithContentsOfURL:urlRequest
encoding:NSUTF8StringEncoding
error:&error];
if (error) {
NSLog(@"Error downloading from URL %@", remoteBundleUrl);
} else {
NSString *currentPackageBundlePath = [self getCurrentPackageBundlePath:&error];
[downloadedBundle writeToFile:currentPackageBundlePath
atomically:YES
encoding:NSUTF8StringEncoding
error:&error];
}
}
+ (void)clearTestUpdates
{
if ([CodePush isUsingTestConfiguration]) {
[[NSFileManager defaultManager] removeItemAtPath:[self getCodePushPath] error:nil];
[[NSFileManager defaultManager] removeItemAtPath:[self getStatusFilePath] error:nil];
}
}
@end