diff options
Diffstat (limited to 'tests/cli-opts.sh')
-rwxr-xr-x | tests/cli-opts.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/cli-opts.sh b/tests/cli-opts.sh index e69de29..39f01f4 100755 --- a/tests/cli-opts.sh +++ b/tests/cli-opts.sh @@ -0,0 +1,54 @@ +#!/bin/sh +set -eu + +. tests/lib.sh + + +test_generates_uuid_with_0_args() { + testing 'generates UUID with 0 arguments' + + N="$LINENO" + OUT="$(mkstemp)" + ERR="$(mkstemp)" + trap 'rm -f "$OUT" "$ERR"' EXIT + STATUS=0 + ./uuid.bin 1>"$OUT" 2>"$ERR" || STATUS=$? + assert_status 0 + assert_empty_stderr + rm "$OUT" "$ERR" + + test_ok +} + +test_checks_string_with_1_arg() { + testing 'checks string with 1 arg' + + N="$LINENO" + OUT="$(mkstemp)" + ERR="$(mkstemp)" + trap 'rm -f "$OUT" "$ERR"' EXIT + STATUS=0 + ./uuid.bin 'cac94e13-41fa-40c4-bd46-5b7b3b46c09e' 1>"$OUT" 2>"$ERR" || STATUS=$? + assert_status 0 + assert_empty_stdout + assert_empty_stderr + rm "$OUT" "$ERR" + + N="$LINENO" + OUT="$(mkstemp)" + ERR="$(mkstemp)" + trap 'rm -f "$OUT" "$ERR"' EXIT + STATUS=0 + ./uuid.bin 'bad-uuid-string' 1>"$OUT" 2>"$ERR" || STATUS=$? + assert_status 3 + assert_empty_stdout + assert_stderr "uuid: str isn't of the correct length" + rm "$OUT" "$ERR" + + test_ok +} + + + +test_generates_uuid_with_0_args +test_checks_string_with_1_arg |