summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Gluck <justin.gluck@livio.io>2019-10-24 10:06:38 -0400
committerJustin Gluck <justin.gluck@livio.io>2019-10-24 10:06:38 -0400
commit09e3d651047dfa49e37c4e6c2a5c9b82d0fa898a (patch)
treedaa3b88f7402dd62cdd61985bfd6825a43e5cf89
parent47e9a2eef6c6c7ae2647ec47b382c8ab29c90db8 (diff)
downloadsdl_ios-bugfix/issue-1454-ListFiles-Disallowed.tar.gz
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m16
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m17
2 files changed, 30 insertions, 3 deletions
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
index 1d1599cad..92eec1f75 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
@@ -157,6 +157,22 @@ describe(@"uploading / deleting single files with the file manager", ^{
});
});
+ describe(@"after receiving a ListFiles error with a resulCode", ^{
+ beforeEach(^{
+ SDLListFilesOperation *operation = testFileManager.pendingTransactions.firstObject;
+ NSMutableDictionary *userInfo = [[NSError sdl_fileManager_unableToStartError].userInfo mutableCopy];
+ userInfo[@"resultCode"] = SDLResultDisallowed;
+ NSError *errorWithResultCode = [NSError errorWithDomain:[NSError sdl_fileManager_unableToStartError].domain code:[NSError sdl_fileManager_unableToStartError].code userInfo:userInfo];
+ operation.completionHandler(NO, initialSpaceAvailable, testInitialFileNames, errorWithResultCode);
+ });
+
+ it(@"should handle the error properly", ^{
+ expect(testFileManager.currentState).to(match(SDLFileManagerStateReady));
+ expect(testFileManager.remoteFileNames).to(beEmpty());
+ expect(@(testFileManager.bytesAvailable)).to(equal(initialSpaceAvailable));
+ });
+ });
+
describe(@"after receiving a ListFiles response", ^{
beforeEach(^{
SDLListFilesOperation *operation = testFileManager.pendingTransactions.firstObject;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m
index bb45a0374..56158c5b8 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLListFilesOperationSpec.m
@@ -18,7 +18,7 @@ describe(@"List Files Operation", ^{
__block NSUInteger bytesAvailableResult = NO;
__block NSError *errorResult = nil;
__block NSArray<NSString *> *fileNamesResult = nil;
-
+
beforeEach(^{
testConnectionManager = [[TestConnectionManager alloc] init];
testOperation = [[SDLListFilesOperation alloc] initWithConnectionManager:testConnectionManager completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSArray<NSString *> * _Nonnull fileNames, NSError * _Nullable error) {
@@ -92,13 +92,24 @@ describe(@"List Files Operation", ^{
badResponse.success = @NO;
badResponse.spaceAvailable = responseSpaceAvailable;
badResponse.filenames = responseFileNames;
-
- [testConnectionManager respondToLastRequestWithResponse:badResponse error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]];
});
it(@"should have called completion handler with error", ^{
+ [testConnectionManager respondToLastRequestWithResponse:badResponse error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]];
+
+ expect(errorResult.localizedDescription).to(match(responseErrorDescription));
+ expect(errorResult.localizedFailureReason).to(match(responseErrorReason));
+ expect(@(successResult)).to(equal(@NO));
+ });
+
+ it(@"should have called completion handler with error including a resultCode ", ^{
+ badResponse.resultCode = SDLResultDisallowed;
+
+ [testConnectionManager respondToLastRequestWithResponse:badResponse error:[NSError sdl_lifecycle_unknownRemoteErrorWithDescription:responseErrorDescription andReason:responseErrorReason]];
+
expect(errorResult.localizedDescription).to(match(responseErrorDescription));
expect(errorResult.localizedFailureReason).to(match(responseErrorReason));
+ expect(errorResult.userInfo[@"resultCode"]).to(equal(@"DISALLOWED"));
expect(@(successResult)).to(equal(@NO));
});
});