Skip to content

Commit

Permalink
fixed UT
Browse files Browse the repository at this point in the history
  • Loading branch information
fchastanet committed Jan 15, 2024
1 parent dccf059 commit dfeb919
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .cspell/softwares.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,9 @@ TRIVY
KICS
TRUFFLEHOG
GRYPE
octocat
prerequest
slurpfile
EJSON
ejson
clairefro
5 changes: 4 additions & 1 deletion .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"**/.idea/**",
"**/report/**",
"**/*.svg",
"**/testsData/**"
"**/testsData/**",
"conf/postmanCli/MongoDbData/MongoDBDataAPI.postman_collection.json",
"conf/postmanCli/GithubAPI/GitHubAPI-01-Basic_no_auth_postman_collection.json",
"conf/postmanCli/GithubAPI/GitHubAPI-02-Advanced_with_auth_postman_collection.json"
]
}
12 changes: 12 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ SPELL_LYCHEE_FILTER_REGEX_EXCLUDE: |
)
JSON_ESLINT_PLUGIN_JSONC_FILE_NAME: .eslintrc.js
JSON_PRETTIER_FILTER_REGEX_EXCLUDE: |
(?x)(
^src/Postman/Model/testsData/pushMode/GithubAPI/notValidJsonFile.json$|
^src/Postman/Collection/testsData/postmanCollections_invalidJsonFile.json$|
^src/Postman/Model/testsData/getCollectionInvalid.json$
)
JSON_ESLINT_PLUGIN_JSONC_FILTER_REGEX_EXCLUDE: |
(?x)(
^src/Postman/Model/testsData/pushMode/GithubAPI/notValidJsonFile.json$|
^src/Postman/Collection/testsData/postmanCollections_invalidJsonFile.json$|
^src/Postman/Model/testsData/getCollectionInvalid.json$
)
8 changes: 4 additions & 4 deletions Commands.tmpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
- [4.1.3. Example 2: connect to mysql container with root user](#413-example-2-connect-to-mysql-container-with-root-user)
- [4.1.4. Example 3: connect to mysql server in order to execute a query](#414-example-3-connect-to-mysql-server-in-order-to-execute-a-query)
- [4.1.5. Example 4: pipe sql command to mysql container](#415-example-4-pipe-sql-command-to-mysql-container)
- [4.1. bin/postmanCli](#41-binpostmancli)
- [4.1.1. Help](#411-help-1)
- [4.2. bin/postmanCli](#42-binpostmancli)
- [4.2.1. Help](#421-help)
- [5. Database tools](#5-database-tools)
- [5.1. bin/dbQueryAllDatabases](#51-bindbqueryalldatabases)
- [5.1.1. Help](#511-help)
Expand Down Expand Up @@ -196,9 +196,9 @@ project-mysql //bin/bash -c 'mysql -h127.0.0.1 -uroot -proot -P3306'
notice that as input is given to the command, tty option is not provided to
docker exec

### 4.1. bin/postmanCli
### 4.2. bin/postmanCli

#### 4.1.1. Help
#### 4.2.1. Help

```text
@@@postmanCli_help@@@
Expand Down
15 changes: 11 additions & 4 deletions bin/postmanCli
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ Postman::Commands::pullCollections() {
echo "${response}" >"${collectionFile}"
Log::displaySuccess "Collection '${collectionName}' has been pulled successfully to '${collectionFile}'"
else
Log::displayError "Collection '${collectionName}' an error occured pulling the collection from postman"
Log::displayError "Collection '${collectionName}' an error occurred pulling the collection from postman"
fi
fi
}
Expand Down Expand Up @@ -958,7 +958,7 @@ Postman::Commands::pushCollections() {
# exists in the model file
# @arg $1 modelFile:String model file in which availableRefs have been retrieved
# @arg $2 availableRefs:&String[] list of known collection references
# @arg $3 modelCollectionRefs:&String[] list ofcollection references to check
# @arg $3 modelCollectionRefs:&String[] list of collection references to check
Postman::Model::checkIfValidCollectionRefs() {
local modelFile="$1"
local -n availableRefs=$2
Expand Down Expand Up @@ -1929,8 +1929,8 @@ postmanCliCommand() {
echo -e "${__HELP_TITLE_COLOR}ARGUMENTS:${__RESET_COLOR}"
echo -e " [${__HELP_OPTION_COLOR}command${__HELP_NORMAL} {single}]"
local -a helpArray
# shellcheck disable=SC2054
helpArray=($'\e[1;34mpull[0m\r\n Pull collections from Postman back to repositories.\r\n\e[1;34mpush[0m\r\n Push repositories collections to Postman.')
# shellcheck disable=SC2054,SC2206
mapfile -t helpArray < <(argCommandHelp)
echo -e " $(Array::wrap2 " " 76 4 "${helpArray[@]}")"
echo -e " [${__HELP_OPTION_COLOR}commandArgs${__HELP_NORMAL} {list} (optional)]"
local -a helpArray
Expand Down Expand Up @@ -2042,6 +2042,13 @@ postmanCliCommand() {
declare optionPostmanModelConfig="$(pwd -P)/postmanCli.collections.json"
declare copyrightBeginYear="2023"

argCommandHelp() {
echo "${__HELP_OPTION_COLOR}pull${__HELP_NORMAL}" $'\r'
echo " Pull collections from Postman back to repositories." $'\r'
echo "${__HELP_OPTION_COLOR}push${__HELP_NORMAL}" $'\r'
echo ' Push repositories collections to Postman.'
}

# shellcheck disable=SC2317 # if function is overridden
unknownOption() {
commandArgs+=("$1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}
]
},
"description": "**WARNING!** Running this request will overwrite an existing file if specified filepath already exists in the provided repo, if you have the proper authorization credentials. Proceed with caution!\n\n## Before making this request \nEncode the file you would like to upload from your computer into base64 using request #1 above. \n\nThat request will save the base64 encoded file to a colelction variable called `encodedFileData`, which will be sent in the body of this request.\n\nEdit the values in the `Params` tab in the request before sending."
"description": "**WARNING!** Running this request will overwrite an existing file if specified filepath already exists in the provided repo, if you have the proper authorization credentials. Proceed with caution!\n\n## Before making this request \nEncode the file you would like to upload from your computer into base64 using request #1 above. \n\nThat request will save the base64 encoded file to a collection variable called `encodedFileData`, which will be sent in the body of this request.\n\nEdit the values in the `Params` tab in the request before sending."
},
"response": [],
"uid": "27246549-fb33abcc-8329-4fa9-9fbb-8e513f9307f6"
Expand Down
2 changes: 1 addition & 1 deletion conf/postmanCli/MongoDbData/Atlas.postman_environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"enabled": true
},
{
"key": "PROJ-INVITATIO-ID",
"key": "PROJ-INVITATION-ID",
"value": "",
"enabled": true
},
Expand Down
2 changes: 1 addition & 1 deletion src/Postman/Commands/pullCollections.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Postman::Commands::pullCollections() {
echo "${response}" >"${collectionFile}"
Log::displaySuccess "Collection '${collectionName}' has been pulled successfully to '${collectionFile}'"
else
Log::displayError "Collection '${collectionName}' an error occured pulling the collection from postman"
Log::displayError "Collection '${collectionName}' an error occurred pulling the collection from postman"
fi
fi
}
Expand Down
2 changes: 1 addition & 1 deletion src/Postman/Model/checkIfValidCollectionRefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# exists in the model file
# @arg $1 modelFile:String model file in which availableRefs have been retrieved
# @arg $2 availableRefs:&String[] list of known collection references
# @arg $3 modelCollectionRefs:&String[] list ofcollection references to check
# @arg $3 modelCollectionRefs:&String[] list of collection references to check
Postman::Model::checkIfValidCollectionRefs() {
local modelFile="$1"
local -n availableRefs=$2
Expand Down
13 changes: 9 additions & 4 deletions src/_binaries/Postman/command.postmanCli.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ Default value: <currentDir>/postmanCli.collections.json' \
--variable-name "optionPostmanModelConfig" \
--function-name optionPostmanModelConfigFunction

argCommandHelp() { :; }
Options::generateArg \
--variable-name "argCommand" \
--min 0 \
--max 1 \
--name "command" \
--authorized-values 'pull|push' \
--help $'${__HELP_OPTION_COLOR}pull${__HELP_NORMAL}\r
Pull collections from Postman back to repositories.\r
${__HELP_OPTION_COLOR}push${__HELP_NORMAL}\r
Push repositories collections to Postman.' \
--help argCommandHelp \
--function-name argCommandFunction

Options::generateArg \
Expand All @@ -62,6 +60,13 @@ Options::generateCommand "${options[@]}"
declare optionPostmanModelConfig="$(pwd -P)/postmanCli.collections.json"
declare copyrightBeginYear="2023"

argCommandHelp() {
echo "${__HELP_OPTION_COLOR}pull${__HELP_NORMAL}" $'\r'
echo " Pull collections from Postman back to repositories." $'\r'
echo "${__HELP_OPTION_COLOR}push${__HELP_NORMAL}" $'\r'
echo ' Push repositories collections to Postman.'
}

# shellcheck disable=SC2317 # if function is overridden
unknownOption() {
commandArgs+=("$1")
Expand Down
6 changes: 4 additions & 2 deletions src/_binaries/Postman/testsData/postmanCli.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ Push/Pull postman collections of all the configured repositories

ARGUMENTS:
[command {single}]
pull   Pull collections from Postman back to repositories.
push   Push repositories collections to Postman.
pull
Pull collections from Postman back to repositories.
push
Push repositories collections to Postman.
[commandArgs {list} (optional)]
list of postman collection's references to pull or push
or no argument to pull or push all the collections
Expand Down

0 comments on commit dfeb919

Please sign in to comment.