From: Andre Noll Date: Sat, 12 Mar 2022 03:29:03 +0000 (+0100) Subject: Add test to check whether empty mood arguments are rejected. X-Git-Tag: v0.7.1~18 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;ds=sidebyside;h=329bf73b72eea2c5be1bcbd9a9602c0a8994d0be;p=paraslash.git Add test to check whether empty mood arguments are rejected. To make sure a recent bug won't be re-introduced. The test succeeds but fails with commit 2c2d3a6ec34d983cb698b245facb8d6240aec1b3 reverted. We have to add at least one mood to trigger the bug. Since addmood is a stdin command we must redirect stdin for the para_client command. It does not hurt to do this for all commands, not just the new one. --- diff --git a/t/t0004-server.sh b/t/t0004-server.sh index 03957464..9e681107 100755 --- a/t/t0004-server.sh +++ b/t/t0004-server.sh @@ -24,7 +24,8 @@ get_audio_file_paths ogg declare -a oggs=($result) declare -a oggs_base=(${oggs[@]##*/}) -declare -a commands=() cmdline=() required_objects=() good=() bad=() +declare -a commands=() cmdline=() required_objects=() good=() bad=() \ + expect_failure=() i=0 commands[$i]="help" cmdline[$i]="help -l" @@ -72,6 +73,15 @@ required_objects[$i]='ogg_afh' cmdline[$i]="ls -l=v ${oggs[@]}" good[$i]='^attributes_txt: 33' +let i++ +commands[$i]='addmood' +cmdline[$i]="addmood test-mood" + +let i++ +commands[$i]='empty-mood-parameter' +cmdline[$i]="select m/" +expect_failure[$i]='true' + let i++ commands[$i]="term" cmdline[$i]="term" @@ -137,14 +147,19 @@ for ((i=0; i < ${#commands[@]}; i++)); do continue fi fi - test_expect_success "$command" " + if [[ -n "${expect_failure[$i]}" ]]; then + f=test_expect_failure + else + f=test_expect_success + fi + $f "$command" " $PARA_CLIENT \ --loglevel $loglevel \ --server-port $port \ --key-file $privkey \ --config-file /dev/null \ -- \ - ${cmdline[$i]} > $command.out && + ${cmdline[$i]} > $command.out < /dev/null && { [[ -z \"${good[$i]}\" ]] || grep \"${good[$i]}\"; } < $command.out && { [[ -z \"${bad[$i]}\" ]] || ! grep \"${bad[$i]}\"; } < $command.out "