-
Notifications
You must be signed in to change notification settings - Fork 1
/
new-test.sh
executable file
·36 lines (33 loc) · 1.34 KB
/
new-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
if [ "$#" -ne 3 ]; then
echo "Expecting to be invoked with 'new-test.sh HTTP_VERB PARTIAL_URL HTTP_RESPONSE_CODE'"
echo "e.g. 'new-test.sh GET /posts/1 200' or 'new-test.sh POST /users 202'"
exit 1
fi
VERB=$(echo $1|tr '[:lower:]' '[:upper:]')
URL=$2
HTTP_CODE=$3
TIMESTAMP=$(date +%Y-%m-%dT%H:%M:%S%z)
if [[ "$OSTYPE" == "darwin"* ]]; then
USER=$(logname)
elif [[ "$OSTYPE" == "win"* ]]; then
USER=%USERNAME%
fi
echo "{}" |
jq --arg VERB $VERB --arg URL $URL '.test_info.id=($VERB)+" "+($URL)' |
jq '.test_info.description = "wilee test case template"' |
jq '.test_info.version = "0.01"' |
jq --arg TIMESTAMP $TIMESTAMP '.test_info.date_uploaded=($TIMESTAMP)' |
jq --arg USER $USER '.test_info.author=($USER)' |
jq '.test_info._comment= "**GENERATED TEMPLATE - NEED TO UPDATE THIS TEST CASE AS IT WILL INITIALLY FAIL**"' |
jq '.test_info.tags=[ "template_only"]' |
jq '.request._comment=""' |
jq --arg VERB $VERB '.request.verb=($VERB)' |
jq --arg URL $URL '.request.url=($URL)' |
jq '.request.headers=[]' |
jq '.request.parameters=[]' |
jq '.request.body=""' |
jq --arg HTTP_CODE $HTTP_CODE '.expect.http_code=($HTTP_CODE|tonumber)' |
# jq '.expect.parse_as="exact_match"' |
jq '.expect.max_latency_ms=0'