summaryrefslogtreecommitdiff
path: root/test/libremessages-test.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 01:52:03 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 01:52:03 -0400
commit4e36277689f92772e474c0829cb7f517aa06d58d (patch)
treea56e6d6c8185a5bd0a1626782b502f98060090db /test/libremessages-test.sh
parentb0b29df10764cecee365815476d83641e668b408 (diff)
add (some) unit tests for librelib and libremessages
Diffstat (limited to 'test/libremessages-test.sh')
-rw-r--r--test/libremessages-test.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/libremessages-test.sh b/test/libremessages-test.sh
new file mode 100644
index 0000000..6da53d1
--- /dev/null
+++ b/test/libremessages-test.sh
@@ -0,0 +1,45 @@
+#!/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 ]]
+}