-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Predictions): Fix of PredicationPlugin unit tests #903
Conversation
} | ||
return AWSTask(error: error!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force unwrap of error should be avoided. I changed it to something like in this Mock class: https://github.com/aws-amplify/amplify-ios/blob/main/AmplifyPlugins/Predictions/AWSPredictionsPluginTests/Mocks/Service/MockComprehendBehavior.swift#L21-L27
Codecov Report
@@ Coverage Diff @@
## main #903 +/- ##
==========================================
+ Coverage 66.32% 67.22% +0.90%
==========================================
Files 870 870
Lines 34434 34581 +147
==========================================
+ Hits 22838 23247 +409
+ Misses 11596 11334 -262
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
let testBundle = Bundle(for: type(of: self)) | ||
guard let url = testBundle.url(forResource: "testImageLabels", withExtension: "jpg") else { | ||
XCTFail("Unable to find image") | ||
return | ||
} | ||
|
||
let errorReceived = expectation(description: "Error should be returned") | ||
errorReceived.expectedFulfillmentCount = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this count 2? It should produce only one error right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, we will address this in another PR.
@@ -62,6 +64,8 @@ class PredictionsServiceTranscribeTests: XCTestCase { | |||
resultStream.alternatives = [alternative] | |||
results.results = [resultStream] | |||
transcriptEvent.transcript = results | |||
transcriptEvent.transcript?.results?.first?.isPartial = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add after line 63 alternative.isPartial = false
and remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of changes:
This PR solved several issues I found in unit tests:
Expectation
,fullfil()
andwait()
to every testAWSTranscribeStreamingClientDelegate
in MockTranscribeStreamingBehavior.swift: https://github.com/aws-amplify/amplify-ios/pull/903/files#diff-36fd00eb37548e02a87ce71ab27eaaf5b486a863f2350501c4059c62efc319a5R39-R40, otherwise, the checking in callback is never run.XCTestCase
instead ofXCTest
otherwise, all the tests are not going to run: https://github.com/aws-amplify/amplify-ios/pull/903/files#diff-9db6d14f94733eac54f7efb37e462e3872117c41f5caf6e47da3504b2a0bc1d6R15Minor things that got fixed:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.