summaryrefslogtreecommitdiff
path: root/test/libremessages-test.sh
blob: 22aad470ce87dd81892f45fd2e5faff74fbab940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 ]]
}