Skip to content
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

docs(postman): update rustman and collection generation docs #3615

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions crates/test_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

The heart of `newman`(with directory support) and `UI-tests`

> If you're developing a collection and you want to learn more about it, click [_**here**_](/README.md)
> [!NOTE]
> If you're developing a collection and you want to learn more about it, click [_**here**_](/postman/README.md)
## Newman

Expand All @@ -14,10 +15,14 @@ The heart of `newman`(with directory support) and `UI-tests`

- Add the connector credentials to the `connector_auth.toml` / `auth.toml` by creating a copy of the `sample_auth.toml` from `router/tests/connectors/sample_auth.toml`
- Export the auth file path as an environment variable:

```shell
export CONNECTOR_AUTH_FILE_PATH=/path/to/auth.toml
```

> [!IMPORTANT]
> You might also need to export the `GATEWAY_MERCHANT_ID`, `GPAY_CERTIFICATE` and `GPAY_CERTIFICATE_KEYS` as environment variables for certain collections with necessary values. Make sure you do that before running the tests
### Supported Commands

Required fields:
Expand All @@ -40,18 +45,21 @@ Optional fields:
- Example: `--header "key1:value1" --header "key2:value2"`
- `--verbose` -- A boolean to print detailed logs (requests and responses)

**Note:** Passing `--verbose` will also print the connector as well as admin API keys in the logs. So, make sure you don't push the commands with `--verbose` to any public repository.
> [!Note]
> Passing `--verbose` will also print the connector as well as admin API keys in the logs. So, make sure you don't push the commands with `--verbose` to any public repository.
### Running tests

- Tests can be run with the following command:

```shell
cargo run --package test_utils --bin test_utils -- --connector-name=<connector_name> --base-url=<base_url> --admin-api-key=<admin_api_key> \
# optionally
--folder "<folder_name_1>,<folder_name_2>,...<folder_name_n>" --verbose
```

**Note**: You can omit `--package test_utils` at the time of running the above command since it is optional.
> [!Note]
> You can omit `--package test_utils` at the time of running the above command since it is optional.
## UI tests

Expand Down
7 changes: 4 additions & 3 deletions postman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ This directory contains the Postman collection for all Hyperswitch supported con

- Make sure that you update the `tests` section where the necessary `javascript` code has to written/updated to test the feature (assertion checks where you verify the results obtained with the expected outcome)
- If certain `tests` need to be run at the time of making a request, make sure you add them to the `Pre-request Script` section of the request
- Make sure that the request body does not contain any comments else the `newman dir-export` command will fail which is used to export the collection to its directory structure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postman does allow using JSON comments in request bodies though:
https://blog.postman.com/introducing-support-for-json-comments-in-request-body/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the dir-export command fails. Might have to check with @knutties to fix it.


---

- After all the development is done, make sure you right click and run the collection in respective environments to make sure that the collection runs successfully
- Export the collection as `v2.1` and save it `postman/collection-json` directory
- Export the postman-collection to its directory structure by using the command `newman dir-export /path/to/collection.json` and move the folder to `postman/collection-dir` (for more info, refer to [Newman-Fork](https://github.com/juspay/hyperswitch/tree/main/crates/test_utils#newman))
- You can run the dir postman collection from newman using `rustman` by referring [here](https://github.com/juspay/hyperswitch/tree/main/crates/test_utils#running-tests)
- Export the collection as `v2.1` and save it `postman/collection-json` directory with file name following the format `<connector_name>.postman_collection.json`
- Export the postman-collection to its directory structure by using the command `newman dir-export /path/to/collection.json` and move the folder to `postman/collection-dir` (for more info, refer to [Newman-Fork](/crates/test_utils/README.md#newman)) with the folder renamed with name of the connector
- You can run the postman collection from directory structure by referring [here](/crates/test_utils/README.md#running-tests)
Loading