summaryrefslogtreecommitdiff
path: root/test/libredbdiff-test.sh
blob: fe73074ce14a507e64743229e01054defcda6be7 (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
47
48
49
#!/usr/bin/env roundup

describe libredbdiff
. ./test-common.sh

common_before() {
	mkdir -p "$XDG_CONFIG_HOME/libretools"
	printf '%s\n' \
	       'statedir="$PWD"' \
	       "mirror_prbl='https://repo.parabola.nu/\$repo/os/\$arch'" \
	       "mirror_arch='https://mirrors.kernel.org/archlinux/\$repo/os/\$arch'" \
	       'repos=(libre)' \
	       > $XDG_CONFIG_HOME/libretools/libredbdiff.conf
}

it_displays_help() {
	LC_ALL=C libredbdiff -h >$tmpdir/stdout 2>$tmpdir/stderr

	[[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
	empty $tmpdir/stderr
}

it_handles_packages_with_multiple_provides_explicit() {
	cd libredbdiff.d/statedir

	libredbdiff -n libre >$tmpdir/stdout 2>$tmpdir/stderr

	empty $tmpdir/stderr
	diff -w ../expected-explicit.txt $tmpdir/stdout
}

it_handles_packages_with_multiple_provides_implicit() {
	cd libredbdiff.d/statedir

	libredbdiff -n >$tmpdir/stdout 2>$tmpdir/stderr

	empty $tmpdir/stderr
	diff -w ../expected-implicit.txt $tmpdir/stdout
}

it_fails_on_bad_repo_args() {
	cd libredbdiff.d/statedir

	libredbdiff -n bogus >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

	[[ $stat != 0 ]]
	empty $tmpdir/stdout
	not empty $tmpdir/stderr
}