Skip to content

Commit 41acae1

Browse files
nickmeinholdwing328
authored andcommitted
Dart fix template tests (#4015)
* Clean up samples directory before fixing tests - removed from samples/client/petstore/dart2 : - purge_test.sh (doesn't seem to be used and not helpful) - openapi folder (is to be re-generated with more meaningful name) - updated dart2-petstore.sh to generate client library with new name - used updated shell script to re-generate client library - updated CI/.drone.yml to use the new client library for tests * Update petstore tests to use faked http client - skipped all of the tests that hit a live endpoint - made a fake http client that can be set to check for expected values and/or return a provided response - added some files with test data recorded from live api calls - updated the README to reflect changes to tests * Update .drone.yml so CI will run the tests
1 parent 8383f26 commit 41acae1

57 files changed

Lines changed: 1018 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CI/.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ steps:
1313
commands:
1414
- (cd samples/client/petstore/dart-jaguar/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
1515
- (cd samples/client/petstore/dart-jaguar/flutter_petstore/openapi && pub get && pub run build_runner build --delete-conflicting-outputs)
16-
- (cd samples/client/petstore/dart2/openapi && pub get && pub run test)
16+
- (cd samples/client/petstore/dart2/petstore && pub get && pub run test)
1717
# test Java 11 HTTP client
1818
- name: java11-test
1919
image: openjdk:11.0

bin/dart2-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ fi
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
3030

3131
# Generate client
32-
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi --additional-properties hideGenerationTimestamp=true $@"
32+
ags="generate -t modules/openapi-generator/src/main/resources/dart2 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/petstore_client_lib --additional-properties hideGenerationTimestamp=true $@"
3333
java $JAVA_OPTS -jar $executable $ags

samples/client/petstore/dart2/petstore/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# Background
2+
3+
## Current state of tests
4+
5+
TL;DR currently the only tests are e2e tests that were adapted to use a faked http client. While pushing data around as a smoke test has some value, more testing is required. In particular we need comprehensive unit/integration tests.
6+
7+
- an old set of e2e tests are skipped for CI, as they hit a live endpoint and so are inherently flaky
8+
- `pet_test.dart`
9+
- `store_test.dart`
10+
- `user_test.dart`
11+
- the above set of tests were adapted to use a faked http client
12+
- the tests are not really well suited to being used with a stubbed client, many are basically just testing the endpoint logic
13+
- while not a great set of tests, they do have some value as a smoke test for template changes
14+
- the adapted tests and files that contain test data:
15+
- `pet_test_fake_client.dart`
16+
- `store_test_fake_client.dart`
17+
- `user_test_fake_client.dart`
18+
- `fake_client.dart`
19+
- `file_upload_response.json`
20+
21+
## Assumptions
22+
23+
- the tests will be run as part of CI and so have access to dart:io
24+
25+
# Running
26+
127
## If not already done, resolve dependencies
228

329
`pub get`
@@ -8,4 +34,4 @@
834

935
## To run all tests in the test folder:
1036

11-
`pub run test test`
37+
`pub run test`

0 commit comments

Comments
 (0)