summaryrefslogtreecommitdiff
path: root/test/librefetch-test.sh
blob: 74089932cd4c06c753863d38f0b4d17ab2325913 (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
#!/usr/bin/env roundup

describe librefetch

. ./test-common.sh

before() {
	_before

	mkdir -p "$HOME"
	printf '%s\n' \
		"DLAGENTS+=(\"libre::$(which librefetch) -p \\\"\\\$BUILDFILE\\\" %u %o\")" \
		'BUILDDIR=""' \
		> "$HOME/.makepkg.conf"

	mkdir -p "$XDG_CONFIG_HOME/libretools"
	printf '%s\n' \
		'MIRROR="phony://example.com/dir/"' \
		'DOWNLOADER=/usr/bin/false' \
		> "$XDG_CONFIG_HOME/libretools/librefetch.conf"
}

after() {
	_after
}

it_displays_help() {
	LANG=C librefetch -h >$tmpdir/stdout 2>$tmpdir/stderr

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

it_cleans_src_libre_first() {
	cp librefetch.d/* "$tmpdir/"
	cd "$tmpdir"

	# create garbage
	mkdir -p src-libre/foo
	touch src-libre/foo/file

	# run librefetch
	makepkg -g

	srcball=src/testpkg-1.0.tar.gz
	bsdtar tf "$srcball" > list-pkg.txt
	diff -u list.txt list-pkg.txt
}