From 68b62fb75f8ae3cd8c3d60be597cd395c8cd34d7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 16 Feb 2022 01:54:59 +0000 Subject: [PATCH] update contribution guideline for new tests --- CONTRIBUTING.md | 75 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 280893cf2..545436026 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -179,35 +179,80 @@ The test algorithm will generate your SDK from a small demo SDK JSON spec file a To get started, create a language file in this location: -`./tests/languages/tests-for-[MY-LANGUAGE].[MY-LANGUAGE-FILE-EXT]` +`./tests/languages//test.[MY-LANGUAGE-FILE-EXT]` In your new language file, init your SDK from a relative path which will be generated here: `./tests/sdks/` from this spec file: `./tests/resources/spec.json`. After you finish initializing, make a series of HTTP calls using your new generated SDKs method just like in one of these examples: -1. tests/languages/tests-for-php.js -2. tests/languages/tests-for-node.js +1. tests/languages/php/test.php +2. tests/languages/node/test.js > Note: In your test files, make sure that you begin the test with the following string "\nTest Started\n". We use this string to filter output from the build tool you're using. -Once done, add a Docker command that can execute your test file to the SDK test algorithm `$containers` array in this location: `./tests/SDKTest.php:17`. Make sure to add one command for each language version you wish to support. +Once done, create a new test file `tests/[Language]Test.php` and update as the following. -A good example is the PHP test for 5 different PHP versions: +```php + 'docker run --rm -v $(pwd):/app -w /app php:5.6-cli php tests/languages/tests-for-php.php', - 'php-7.0' => 'docker run --rm -v $(pwd):/app -w /app php:7.0-cli php tests/languages/tests-for-php.php', - 'php-7.1' => 'docker run --rm -v $(pwd):/app -w /app php:7.1-cli php tests/languages/tests-for-php.php', - 'php-7.2' => 'docker run --rm -v $(pwd):/app -w /app php:7.2-cli php tests/languages/tests-for-php.php', - 'php-7.3' => 'docker run --rm -v $(pwd):/app -w /app php:7.3-cli php tests/languages/tests-for-php.php', - 'php-7.4' => 'docker run --rm -v $(pwd):/app -w /app php:7.4-cli php tests/languages/tests-for-php.php', -]; + 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/dart dart:stable sh -c "dart pub get && dart pub run tests/tests.dart"', + 'dart-beta' => 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/dart dart:beta sh -c "dart pub get && dart pub run tests/tests.dart"', + ]; + protected array $expectedOutput = [ + ...Base::FOO_RESPONSES, + ...Base::BAR_RESPONSES, + ...Base::GENERAL_RESPONSES, + ...Base::EXCEPTION_RESPONSES, + ]; +} ``` -Finally, you can run the tests using +Also in `.travis.yml` add new env `SDK=[Language]` so that travis will run test for this language as well. + +Finally, you can run tests using ```sh -docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/docker.sock php:7.4-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit tests/SDKTest.php" +docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/docker.sock php:7.4-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit" ``` ## SDK Generator Interface