Skip to content

Commit c4d5cb9

Browse files
authored
CLOUDP-278958: trasformation test (#306)
1 parent 7a1fb77 commit c4d5cb9

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

.github/workflows/release-postman.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ jobs:
3939
BASE_URL: ${{ inputs.atlas_prod_base_url }}
4040
working-directory: ./tools/postman
4141
run: |
42-
make transform_collection
42+
make transform_collection
43+
make transform_collection_test
4344
4445
- name: Upload Collection to Postman
4546
env:

tools/postman/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ convert_to_collection:
1717
transform_collection:
1818
./scripts/transform-for-api.sh
1919

20+
.PHONY: transform_collection_test
21+
transform_collection_test:
22+
./scripts/transform-for-api-test.sh
23+
2024
.PHONY: upload_collection
2125
upload_collection:
2226
./scripts/upload-collection.sh

tools/postman/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ The OpenAPI path for Postman generation and configured feature flags can also be
8585

8686
Once env vars are configured, the setup scripts can be run locally using the Make following commands:
8787
- `make fetch_openapi`
88-
- `make convert_to_collection`
89-
- `make transform_collection`
90-
- `make upload_collection`
88+
- `make convert_to_collection` - covert OpenAPI to Postman collection
89+
- `make transform_collection` - transform Postman collection to fix common issues
90+
- `make transform_collection_test` - test collection.
91+
- `make upload_collection` - uploads collection to the Postman
9192

9293
## Automatic updates
9394

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
#########################################################
5+
# Test for transformation
6+
# To be run after transformation is done
7+
#########################################################
8+
9+
COLLECTION_FILE_NAME=${COLLECTION_FILE_NAME:-"collection.json"}
10+
TMP_FOLDER=${TMP_FOLDER:-"../tmp"}
11+
COLLECTION_TRANSFORMED_FILE_NAME=${COLLECTION_TRANSFORMED_FILE_NAME:-"collection-transformed.json"}
12+
13+
pushd "${TMP_FOLDER}"
14+
15+
# Ensure the necessary files exist
16+
if [[ ! -f "$COLLECTION_FILE_NAME" ]]; then
17+
echo "Error: Collection file not found at $COLLECTION_FILE_NAME"
18+
exit 1
19+
fi
20+
21+
# Test: Disable query params by default
22+
echo "Disabling query params by default test"
23+
if jq -e '.. | select(.request? != null).request.url.query[] | select(.disabled == true)' "$COLLECTION_TRANSFORMED_FILE_NAME" > /dev/null; then
24+
echo "Test Passed: Query params disabled successfully."
25+
else
26+
echo "Test Failed: Query params disabling failed."
27+
fi
28+
29+
# Test: Remove _postman_id
30+
if ! jq -e '.collection.info._postman_id' "$COLLECTION_TRANSFORMED_FILE_NAME" > /dev/null; then
31+
echo "Test Passed: _postman_id removed successfully."
32+
else
33+
echo "Test Failed: _postman_id removal failed."
34+
fi
35+
36+
# Test : Add baseUrl property
37+
echo "Adding baseUrl property test"
38+
if jq -e '.collection.variable[0] | (.key == "baseUrl" and has("value"))' "$COLLECTION_TRANSFORMED_FILE_NAME" > /dev/null; then
39+
echo "Test Passed: The first item in the variable array has key set to \"baseUrl\" and has a value property."
40+
else
41+
echo "Test Failed: The first item in the variable array does not have the expected key or value properties."
42+
fi
43+

0 commit comments

Comments
 (0)