@@ -18,70 +18,26 @@ if [[ ! -f "$COLLECTION_FILE_NAME" ]]; then
1818 exit 1
1919fi
2020
21-
22- # Test: Wrap Collection in "collection" tag
23- echo " Wrapping Collection $COLLECTION_FILE_NAME in \" collection\" tag"
24- jq ' {"collection": .}' " $COLLECTION_FILE_NAME " > intermediateCollectionWrapped.json
25-
26- if jq -e ' .collection' intermediateCollectionWrapped.json > /dev/null; then
27- echo " Test Passed: Collection wrapped successfully."
28- else
29- echo " Test Failed: Collection wrapping failed."
30- fi
31-
3221# Test: Disable query params by default
33- echo " Disabling query params by default"
34- # jq '(.. | select(.request? != null).request.url.query[].disabled) = true' \
35- # intermediateCollectionWrapped.json > intermediateCollectionDisableQueryParam.json
36-
37- if jq -e ' .. | select(.request? != null).request.url.query[] | select(.disabled == true)' intermediateCollectionDisableQueryParam.json > /dev/null; then
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
3824 echo " Test Passed: Query params disabled successfully."
3925else
4026 echo " Test Failed: Query params disabling failed."
4127fi
4228
4329# Test: Remove _postman_id
44- # echo "Removing _postman_id"
45- # jq 'del(.collection.info._postman_id)' \
46- # intermediateCollectionDisableQueryParam.json > intermediateCollectionNoPostmanID.json
47-
48- if ! jq -e ' .collection.info._postman_id' intermediateCollectionNoPostmanID.json > /dev/null; then
30+ if ! jq -e ' .collection.info._postman_id' $COLLECTION_TRANSFORMED_FILE_NAME > /dev/null; then
4931 echo " Test Passed: _postman_id removed successfully."
5032else
5133 echo " Test Failed: _postman_id removal failed."
5234fi
5335
54- # Test: Remove circular references
55- echo " Removing circular references"
56- sed ' s/\\"value\\": \\"<Circular reference to #[^>"]* detected>\\"//g' intermediateCollectionNoPostmanID.json > intermediateCollectionNoCircular.json
57-
58- if ! grep -q ' <Circular reference to #' intermediateCollectionNoCircular.json; then
59- echo " Test Passed: Circular references removed successfully."
60- else
61- echo " Test Failed: Circular references removal failed."
62- fi
63-
64- # Test: Remove all variables
65- echo " Removing all variables. We use environment for variables instead"
66- jq ' .collection.variable = []' \
67- intermediateCollectionWithDescription.json > intermediateCollectionWithNoVarjson.json
68-
69- if jq -e ' .collection.variable | length == 0' intermediateCollectionWithNoVarjson.json > /dev/null; then
70- echo " Test Passed: Variables removed successfully."
71- else
72- echo " Test Failed: Variables removal failed."
73- fi
74-
7536# Test : Add baseUrl property
76- echo " Adding baseUrl property $BASE_URL "
77- jq --arg base_url " $BASE_URL " \
78- ' .collection.variable[0].value = $base_url' \
79- intermediateCollectionWithNoVarjson.json > intermediateCollectionWithBaseURL.json
80-
81- if jq -e --arg base_url " $BASE_URL " ' .collection.variable[0].value == $base_url' intermediateCollectionWithBaseURL.json > /dev/null; then
82- echo " Test Passed: baseUrl property added successfully."
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."
8340else
84- echo " Test Failed: baseUrl property addition failed ."
41+ echo " Test Failed: The first item in the variable array does not have the expected key or value properties ."
8542fi
8643
87- # End of test script
0 commit comments