lightning-runner/test/test-arguments

61 lines
974 B
Plaintext
Raw Permalink Normal View History

2023-03-06 03:08:55 +00:00
#!/usr/bin/env bash
testArgumentsBecomeVars() {
echo '
#!/usr/bin/env bash
⚡banana() {
_argument hello
if [[ -n "$_arg_hello" ]]; then
echo "I AM A BANANA"
fi
}
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go banana hello=please
assertEquals "I AM A BANANA" "$STDOUT"
}
testArgumentsNotDeclaredDoNot() {
echo '
#!/usr/bin/env bash
⚡banana() {
_argument hello
if [[ -n "$_arg_goodbye" ]]; then
echo "I AM A BANANA"
fi
}
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go banana goodbye=foo
assertEquals "" "$STDOUT"
}
2023-03-06 03:42:37 +00:00
testRequiredArgumentsAreRequired() {
echo '
#!/usr/bin/env bash
⚡banana() {
_required_argument hello
echo "$_arg_hello"
}
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go banana
assertContains "$STDERR" "'hello' is a required argument"
assertEquals 1 "$EXIT_CODE"
}
2023-03-06 03:08:55 +00:00
source $(dirname $0)/runner