Pass parameters individually to the test

This way we can properly quote path.
This commit is contained in:
Michal Čihař
2017-11-08 15:38:10 +01:00
parent 925a4bc163
commit ac2acfdcd2

View File

@@ -9,17 +9,17 @@ unset SDCV_PAGER
unset STARDICT_DATA_DIR unset STARDICT_DATA_DIR
test_json() { test_json() {
PARAMS="$1" EXPECTED=$(echo "$1" | jq 'sort')
EXPECTED=$(echo "$2" | jq 'sort') shift
RESULT=$($SDCV $PARAMS | jq 'sort') RESULT=$($SDCV "$@" | jq 'sort')
if [ "$EXPECTED" != "$RESULT" ]; then if [ "$EXPECTED" != "$RESULT" ]; then
echo "expected $EXPECTED but got $RESULT" echo "expected $EXPECTED but got $RESULT"
exit 1 exit 1
fi fi
} }
test_json "-x -j -l -n --data-dir $TEST_DIR" "[{\"name\": \"Test synonyms\", \"wordcount\": \"2\"},{\"name\": \"Sample 1 test dictionary\", \"wordcount\": \"1\"},{\"name\": \"test_dict\", \"wordcount\": \"1\"}]" test_json "[{\"name\": \"Test synonyms\", \"wordcount\": \"2\"},{\"name\": \"Sample 1 test dictionary\", \"wordcount\": \"1\"},{\"name\": \"test_dict\", \"wordcount\": \"1\"}]" -x -j -l -n --data-dir "$TEST_DIR"
test_json "-x -j -n --data-dir $TEST_DIR foo" "[{\"dict\": \"Test synonyms\",\"word\":\"test\",\"definition\":\"\\\nresult of test\"}]" test_json "[{\"dict\": \"Test synonyms\",\"word\":\"test\",\"definition\":\"\\\nresult of test\"}]" -x -j -n --data-dir "$TEST_DIR" foo
test_json "-x -j -n --data-dir $TEST_DIR foobarbaaz" "[]" test_json "[]" -x -j -n --data-dir "$TEST_DIR" foobarbaaz
exit 0 exit 0