-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add happy-path test cases for Model and ApiClient (#16)
Refactor `ApiClient` to go from `Map` to `Map` instead of bytes to `String`. This makes it easier to write a stub client which is agnostic to the ordering of values in the maps. Move the responsibilities for UTF8 and JSON encoding to the `HttpApiClient`. Eagerly call nested `.toJson()` methods for child fields in `.toJson()` implementations. This allows deep equality checking for the stub client without implementing `operator ==` for the data model classes. Add a `createModelWithClient` method in `src/model.dart` which will not be exported to the package public API. Use it in the test to create a model with a stubbed client. Add tests for each call in `GenerativeModel`. Tests validate - Encoding from arguments to the JSON schema. - Building the correct `Uri` for the task and model. - Parsing the result to the Dart data model. Add tests for unary and streaming calls in `HttpClient`. Tests validate - Headers are set correctly. - Encoding and decoding UTF8 and JSON. - Using streaming with `alt=sse` query parameter and parsing of `data: ` lines in the response. Add Matcher helper methods for classes checked during tests that don't have `operator ==`.
- Loading branch information
Showing
9 changed files
with
460 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.