diff --git a/sdk/test/README.md b/sdk/test/README.md index 316215de5..051a2613f 100644 --- a/sdk/test/README.md +++ b/sdk/test/README.md @@ -14,11 +14,11 @@ Processing GET cases... Processing POST cases... ``` - If nothing else is outputted then all tests passed ! +If nothing else is output then all tests passed! - Results of the test can be found in `./get_cases/$case_name/testOutput.txt` (or `post_cases` depending on the test). +Results of the test can be found in `./get_cases/$case_name/testOutput.txt` (or `post_cases` depending on the test). - Take note that these tests are stricter about data line ordering then the SDK spec is, but unless that becomes an actual problem I dont intend to fix it, since it would add complexity. +Take note that these tests are stricter about data line ordering then the SDK spec is, but unless that becomes an actual problem I dont intend to fix it, since it would add complexity. ## Adding new cases @@ -27,6 +27,7 @@ Processing POST cases... That folder must contain an `input.json` file and an `output.txt` file. The `input.json` file must contain valid json of the following shape: + ``` {"events": [ @@ -54,7 +55,4 @@ data: attributes type text/javascript data: attributes blocking false data: autoRemove false data: script console.log('hello'); - - ``` - diff --git a/sdk/test/test-all.sh b/sdk/test/test-all.sh index e7ce839b8..04962f204 100755 --- a/sdk/test/test-all.sh +++ b/sdk/test/test-all.sh @@ -1,7 +1,5 @@ #!/bin/sh -#!/bin/sh - # Check if an argument is provided if [ -z "$1" ]; then echo "Usage: $0 " @@ -18,6 +16,7 @@ if [ -d "./get-cases" ]; then ./test-get.sh "$case" "$1" fi done + echo "Finished processing GET cases" else echo "Directory './get-cases' not found!" fi @@ -30,6 +29,7 @@ if [ -d "./post-cases" ]; then ./test-post.sh "$case" "$1" fi done + echo "Finished processing POST cases" else echo "Directory './post-cases' not found!" -fi \ No newline at end of file +fi diff --git a/sdk/test/test-get.sh b/sdk/test/test-get.sh index 0425e50f8..8f7ca076e 100755 --- a/sdk/test/test-get.sh +++ b/sdk/test/test-get.sh @@ -4,8 +4,13 @@ [ ! -f "$1/output.txt" ] && echo "case $1 does not have output.txt" && return 1 input=$(cat "$1/input.json") + +rm "$1/testOutput.txt" + curl -sN --get --data-urlencode "datastar=$input" "$2/test" -o "$1/testOutput.txt" +[ ! -f "$1/testOutput.txt" ] && echo "case $1 failed: your server did not return anything" && return 1 + diff -q "$1/testOutput.txt" "$1/output.txt" return 0 diff --git a/sdk/test/test-post.sh b/sdk/test/test-post.sh index f7e876e86..66270abea 100755 --- a/sdk/test/test-post.sh +++ b/sdk/test/test-post.sh @@ -3,9 +3,13 @@ [ ! -f "$1/input.json" ] && echo "case $1 does not have input.json" && return 1 [ ! -f "$1/output.txt" ] && echo "case $1 does not have output.txt" && return 1 +rm "$1/testOutput.txt" + input=$(cat "$1/input.json") curl -sN --json "$input" "$2/test" -o "$1/testOutput.txt" +[ ! -f "$1/testOutput.txt" ] && echo "case $1 failed: your server did not return anything" && return 1 + diff -q "$1/testOutput.txt" "$1/output.txt" return 0