diff options
Diffstat (limited to 'test/lib-messages-test.sh')
-rw-r--r-- | test/lib-messages-test.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh new file mode 100644 index 0000000..d895d99 --- /dev/null +++ b/test/lib-messages-test.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env roundup + +describe libremessages + +. ./test-common.sh + +before() { + _before +} + +after() { + _after +} + +it_can_be_included_twice() ( + . libremessages + . libremessages +) + +it_can_be_included_with_set_euE() ( + set -euE + . libremessages +) + +it_works_with_no_color_and_set_euE() ( + ( + unset TERM + set -euE + . libremessages + msg Foo + ) >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stdout + not empty $tmpdir/stderr +) + +it_can_be_called_without_including() { + libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_with_msg_and_no_args() { + ret=0 + libremessages msg || ret=$? + [[ $ret != 0 ]] +} + +it_allows_subheadings_to_flag() { + # Note that old versions of `flag` panicked if given an odd + # number of headings, so give an odd number here. + libremessages flag \ + -a adesc \ + -b bdesc \ + Head1: \ + -c cdesc > $tmpdir/out + printf '%s\n' \ + ' -a adesc' \ + ' -b bdesc' \ + ' Head1:' \ + ' -c cdesc' > $tmpdir/exp + diff -u $tmpdir/exp $tmpdir/out +} |