Repository navigation
ci(dart): add unit tests and end-to-end sample execution to quickstart workflow - #9313
Conversation
Add a printed confirmation message upon successful completion of the DELETE request in the Dart quickstart CLI application, aligning output behavior with other Kiota language quickstart samples. Signed-off-by: Hardik Kaurani <[email protected]>
Ignore conventional Dart build and compilation artifacts (.packages, build/, and bin/*.exe) to ensure clean working copies during local analysis and compilation. Signed-off-by: Hardik Kaurani <[email protected]>
… quickstart tests Add unit tests verifying that PostsClient properly initializes with DefaultRequestAdapter and configures the default base URL against JSONPlaceholder. Signed-off-by: Hardik Kaurani <[email protected]>
… posts Add unit tests asserting that PostsRequestBuilder generates accurate RequestInformation for GET operations, sets the application/json Accept header, and maps configured query parameters (userId and title). Signed-off-by: Hardik Kaurani <[email protected]>
…operations Add unit tests asserting that toPostRequestInformation serializes the request payload and that byPostId correctly formats path parameters for individual item GET and DELETE operations. Signed-off-by: Hardik Kaurani <[email protected]>
Add unit tests verifying Post model field getters and setters as well as registration of property parsers within getFieldDeserializers. Signed-off-by: Hardik Kaurani <[email protected]>
Add a 'Run tests' step invoking 'dart test' in the build-quickstart-dart job so that unit tests in get-started/quickstart/dart/test are verified during continuous integration. Signed-off-by: Hardik Kaurani <[email protected]>
…rkflow Add a 'Run quickstart sample' step executing 'dart run ./bin/cli.dart' in the build-quickstart-dart job to verify end-to-end client execution and live request/response serialization against JSONPlaceholder in CI. Signed-off-by: Hardik Kaurani <[email protected]>
|
While reviewing the quickstart samples across languages, I noticed that the Dart quickstart workflow ( Additionally, This PR adds:
All checks and tests pass locally:
Whenever you have a moment, I'd appreciate your review. Thank you! |
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
4 open issues
Running the quickstart in CI likely performs live HTTP calls (e.g., to jsonplaceholder), which can… · New Using relative imports fromtest/intolib/-style code is brittle (breaks more easily when the… · New These assertions couple the test to the URL-encoded path parameter key (post%2Did). This is an… · New These locals are not reassigned withinsetUp, sofinalis more appropriate thanvarand… · New
Review effort: Lite
| working-directory: get-started/quickstart/dart | ||
|
|
||
| - name: Run quickstart sample | ||
| run: dart run ./bin/cli.dart |
There was a problem hiding this comment.
Addressed in b1ed447. Removed the live HTTP sample execution step from get-started-dart.yml to prevent flakiness from external network dependencies and rate limits, relying on the deterministic unit test suite instead.
| import '../client/models/post.dart'; | ||
| import '../client/posts_client.dart'; |
There was a problem hiding this comment.
In this sample, the client is generated directly at the quickstart root under get-started/quickstart/dart/client/, outside lib/, alongside bin/ and test/, following the standard Kiota quickstart layout. Since it resides outside lib/, Dart's package: scheme cannot resolve it directly, so relative imports from sibling directories are consistent with the existing pattern in bin/cli.dart.
Also removed the unused template stub and package:cli import in b1ed44759.
| expect(getInfo.pathParameters['post%2Did'], 5); | ||
|
|
||
| var deleteInfo = itemReq.toDeleteRequestInformation(); | ||
| expect(deleteInfo.httpMethod, HttpMethod.delete); | ||
| expect(deleteInfo.pathParameters['post%2Did'], 5); |
There was a problem hiding this comment.
Addressed in b1ed447. Decoupled path parameter assertions from the internal URL-encoded key name by checking that pathParameters.values contains 5 for both GET and DELETE request information.
| var authProvider = AnonymousAuthenticationProvider(); | ||
| var requestAdapter = DefaultRequestAdapter(authProvider: authProvider); |
There was a problem hiding this comment.
Addressed in b1ed44759. Replaced var with final for all local variables that are not reassigned across setUp and all test cases.
…remove live ci call - Remove live HTTP run step in get-started-dart.yml to prevent CI flakiness from external services. - Assert path parameter presence via values rather than URL-encoded parameter key. - Use final for immutable local variables in test setup and test cases. - Remove unused default template calculate test and package import. Signed-off-by: Hardik Kaurani <[email protected]>
|
Hi Vincent Biret (@baywet), pushed an update addressing the review feedback:
All unit tests ( |



Summary
In
get-started/quickstart/dart, the continuous integration workflow (.github/workflows/get-started-dart.yml) previously only analyzed source files and compiledbin/cli.dartinto an executable without running any test assertions or validating end-to-end client execution. Additionally,test/cli_test.dartcontained only a template stub, leaving client initialization, request information generation, query parameter mapping, and model serialization untested. Finally,bin/cli.dartwas missing a deletion completion log, unlike other language quickstarts.This pull request completes the Dart quickstart test coverage and aligns its CI pipeline with other languages in
kiota-samples(such as Python, PHP, TypeScript, and Go).Changes
Parity in Quickstart CLI:
print('Deleted post');inget-started/quickstart/dart/bin/cli.dartfollowing the DELETE request.Standard Build Artifact Ignore:
get-started/quickstart/dart/.gitignoreto ignore.packages,build/, andbin/*.exe.Comprehensive Dart Quickstart Unit Tests:
get-started/quickstart/dart/test/cli_test.dartto verify:PostsClientinitialization withAnonymousAuthenticationProviderandDefaultRequestAdapter, including base URL validation (https://jsonplaceholder.typicode.com).Accept: application/jsonheaders and URL template formatting.userIdandtitlefiltering.post%2Did) for single-item GET and DELETE operations.Postmodel properties and field deserializer registrations.CI Workflow Verification:
Run testsstep (dart test) in.github/workflows/get-started-dart.yml.Run quickstart samplestep (dart run ./bin/cli.dart) in.github/workflows/get-started-dart.ymlto verify end-to-end live API execution against JSONPlaceholder.Verification
dart analyze --fatal-infos: 0 issues found.dart test: 7/7 unit tests passed.dart compile exe ./bin/cli.dart: Succeeded.dart run ./bin/cli.dart: Successfully executed all CRUD operations against JSONPlaceholder.