@@ -191,23 +191,35 @@ - (void)testDiskAgeLimit {
191191 FirehoseRecorder.diskAgeLimit = 0.0 ;
192192}
193193
194- - (void )testAll {
195- AWSFirehoseRecorder *firehoseRecorder = [AWSFirehoseRecorder defaultFirehoseRecorder ];
196-
197- NSMutableArray *tasks = [NSMutableArray new ];
198- for (int32_t i = 0 ; i < 1234 ; i++) {
199- [tasks addObject: [firehoseRecorder saveRecord: [[NSString stringWithFormat: @" TestString-%02d \n " , i] dataUsingEncoding: NSUTF8StringEncoding]
200- streamName: AWSFirehoseRecorderTestStream]];
201- }
202-
203- [[[[AWSTask taskForCompletionOfAllTasks: tasks] continueWithSuccessBlock: ^id (AWSTask *task) {
204- sleep (10 );
205- return [firehoseRecorder submitAllRecords ];
206- }] continueWithBlock: ^id (AWSTask *task) {
207- XCTAssertNil (task.error );
208-
194+ - (void )testSubmitAllRecordsReturnsErrorOnInvalidPoolId {
195+ XCTestExpectation *expectation = [self expectationWithDescription: @" Test finished running." ];
196+
197+ NSString *poolId = @" invalidPoolId" ;
198+ AWSCognitoCredentialsProvider *invalidCreds = \
199+ [[AWSCognitoCredentialsProvider alloc ] initWithRegionType: AWSRegionUSEast1
200+ identityPoolId: poolId];
201+
202+ AWSServiceConfiguration *configuration = \
203+ [[AWSServiceConfiguration alloc ] initWithRegion: AWSRegionUSEast1
204+ credentialsProvider: invalidCreds];
205+
206+ [AWSFirehoseRecorder registerFirehoseRecorderWithConfiguration: configuration
207+ forKey: poolId];
208+ AWSFirehoseRecorder *firehoseRecorder = [AWSFirehoseRecorder FirehoseRecorderForKey: poolId];
209+ [firehoseRecorder saveRecord: [@" testString" dataUsingEncoding: NSUTF8StringEncoding]
210+ streamName: @" streamName" ];
211+
212+ AWSTask *submitTask = firehoseRecorder.submitAllRecords ;
213+
214+ [submitTask continueWithBlock: ^id (AWSTask *task) {
215+ XCTAssertNotNil (task.error , @" Task should have an error due to invalid pool id." );
216+ [expectation fulfill ];
209217 return nil ;
210- }] waitUntilFinished ];
218+ }];
219+
220+ [self waitForExpectationsWithTimeout: 5 handler: ^(NSError * _Nullable error) {
221+ XCTAssertNil (error);
222+ }];
211223}
212224
213225@end
0 commit comments