Showing 1 of 1 files from the diff.
@@ -323,6 +323,7 @@
Loading
323 | 323 | /// |
|
324 | 324 | func testIdentifyAllLabelsServiceWithNilResponse() { |
|
325 | 325 | setUpAmplify() |
|
326 | + | ||
326 | 327 | mockRekognition.setAllLabelsResponse(labelsResult: nil, moderationResult: nil) |
|
327 | 328 | ||
328 | 329 | let testBundle = Bundle(for: type(of: self)) |
@@ -346,6 +347,43 @@
Loading
346 | 347 | waitForExpectations(timeout: 1) |
|
347 | 348 | } |
|
348 | 349 | ||
350 | + | /// Test whether error is prograted correctly when making a rekognition call to identify all labels |
|
351 | + | /// |
|
352 | + | /// - Given: Predictions service with rekognition behavior |
|
353 | + | /// - When: |
|
354 | + | /// - I invoke rekognition api in predictions service |
|
355 | + | /// - Set mockLabelsResponse as labelsResult, set moderationResult to be nil |
|
356 | + | /// - Then: |
|
357 | + | /// - I should get back a service error because moderation response is nil |
|
358 | + | /// |
|
359 | + | func testIdentifyAllLabelsServiceWithNilModerationResponse() { |
|
360 | + | setUpAmplify() |
|
361 | + | ||
362 | + | let mockLabelsResponse: AWSRekognitionDetectLabelsResponse = AWSRekognitionDetectLabelsResponse() |
|
363 | + | mockLabelsResponse.labels = [AWSRekognitionLabel]() |
|
364 | + | ||
365 | + | mockRekognition.setAllLabelsResponse(labelsResult: mockLabelsResponse, moderationResult: nil) |
|
366 | + | ||
367 | + | let testBundle = Bundle(for: type(of: self)) |
|
368 | + | guard let url = testBundle.url(forResource: "testImageLabels", withExtension: "jpg") else { |
|
369 | + | XCTFail("Unable to find image") |
|
370 | + | return |
|
371 | + | } |
|
372 | + | let errorReceived = expectation(description: "Error should be returned") |
|
373 | + | ||
374 | + | predictionsService.detectLabels(image: url, type: .all) { event in |
|
375 | + | switch event { |
|
376 | + | case .completed(let result): |
|
377 | + | XCTFail("Should not produce result: \(result)") |
|
378 | + | case .failed(let error): |
|
379 | + | XCTAssertNotNil(error, "Should produce an error") |
|
380 | + | errorReceived.fulfill() |
|
381 | + | } |
|
382 | + | } |
|
383 | + | ||
384 | + | waitForExpectations(timeout: 1) |
|
385 | + | } |
|
386 | + | ||
349 | 387 | /// Test whether error is prograted correctly when making a rekognition call to identify all labels |
|
350 | 388 | /// |
|
351 | 389 | /// - Given: Predictions service with rekognition behavior |
Files | Coverage |
---|---|
Amplify | 45.70% |
AmplifyPlugins | 68.34% |
AmplifyTestApp | 44.44% |
AmplifyTestCommon | 25.61% |
AmplifyTests | 91.41% |
Project Totals (874 files) | 66.89% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.