summaryrefslogtreecommitdiff
path: root/test/lib-messages-test.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-01 11:56:57 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-05 19:53:57 -0600
commite1e82671870076a73766e628f8755a1f7e0afe11 (patch)
treec38bf676bb34d73de5af3891e3648a5e6f15e62c /test/lib-messages-test.sh
parent47722999c8cb00e6f0be036aa8b620fcd0ca861c (diff)
reorganize the tests a bit
Diffstat (limited to 'test/lib-messages-test.sh')
-rw-r--r--test/lib-messages-test.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh
new file mode 100644
index 0000000..22aad47
--- /dev/null
+++ b/test/lib-messages-test.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env roundup
+
+describe libremessages
+
+before() {
+ tmpdir=$(mktemp -d --tmpdir test-libremessages.XXXXXXXXXXXX)
+}
+
+after() {
+ rm -rf -- "$tmpdir"
+}
+
+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
+
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+)
+
+it_can_be_called_without_including() {
+ libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_fails_with_msg_and_no_args() {
+ ret=0
+ libremessages msg || ret=$?
+ [[ $ret != 0 ]]
+}