diff --git a/unit-tests/bin/crm_ticket b/unit-tests/bin/crm_ticket index cd0adfa..cf69761 100755 --- a/unit-tests/bin/crm_ticket +++ b/unit-tests/bin/crm_ticket @@ -1,49 +1,52 @@ #!/bin/bash # # "fake" crm_ticket for unit tests. # * Ignores set,grant,revoke actions # * returns values it gets asked for from UNIT_TEST_AUX function word_after() { +# Per default $1 is printed perl -e ' $search=shift(); $stg=shift(); - print $1 if $stg =~ /$search/;' "$1" "$2" + print $'${3:-1}' if $stg =~ /$search/;' "$1" "$2" } function Get() { - which=$(word_after " -G '(\\w+)'" "$1") + which=$(word_after " -G ('?)(\\w+)\\1" "$1" 2) if [[ -z "$which" ]] ; then exit 1 fi word_after "\\b$which\\b (\\S+)" "$UNIT_TEST_AUX" + # provide a newline + echo "" exit 0 } # include resp. supersede with per-test functions inc="${UNIT_TEST_FILE%.txt}.sh" if [[ -e "$inc" ]] ; then . "$inc" fi if [[ "$*" == *" -G "* ]] ; then Get "$*" elif [[ "$*" == *" -g "* ]] ; then : # grant elif [[ "$*" == *" -r "* ]] ; then : # revoke elif [[ "$*" == *" -S "* ]] ; then : # set else echo "not understood" >&2 exit 1 fi