mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-18 12:52:42 +03:00
tiny-cloud: Print usage on invalid option and add test
Add test that verifies invalid option and `tiny-cloud --help`
This commit is contained in:
parent
7ad4565a04
commit
02c0c31703
@ -21,8 +21,8 @@ bootstrap_incomplete() {
|
|||||||
rm -f "$TINY_CLOUD_VAR/.bootstrap-complete"
|
rm -f "$TINY_CLOUD_VAR/.bootstrap-complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
args=$(getopt -o hsb: --long help,setup,bootstrap: -n ${0##*/} -- "$@")
|
args=$(getopt -o hsb: --long help,setup,bootstrap: -n ${0##*/} -- "$@") || { usage >&2; exit 1; }
|
||||||
if [ $? -ne 0 ] || [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
usage >&2
|
usage >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
19
tests/tiny-cloud.test
Executable file
19
tests/tiny-cloud.test
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env atf-sh
|
||||||
|
|
||||||
|
. $(atf_get_srcdir)/test_env.sh
|
||||||
|
|
||||||
|
export PREFIX="$srcdir"
|
||||||
|
export MOCK=echo
|
||||||
|
|
||||||
|
init_tests \
|
||||||
|
tiny_cloud_help
|
||||||
|
|
||||||
|
tiny_cloud_help_body() {
|
||||||
|
CLOUD=nocloud atf_check -s not-exit:0 \
|
||||||
|
-e match:"Usage" \
|
||||||
|
tiny-cloud --invalid
|
||||||
|
|
||||||
|
CLOUD=nocloud atf_check -s exit:0 \
|
||||||
|
-o match:"Usage" \
|
||||||
|
tiny-cloud --help
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user