summaryrefslogtreecommitdiff
path: root/test/librerelease-test.sh
blob: 0fc1089fcc34f0dc70aa9853e5ed9eab83a18b88 (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 librestage

. ./test-common.sh

before() {
	_before

	mkdir -p $XDG_CONFIG_HOME/libretools
	echo "WORKDIR='$tmpdir/workdir'" >$XDG_CONFIG_HOME/libretools/libretools.conf

	export HOME=$XDG_CONFIG_HOME
	echo 'PKGEXT=.pkg.tar.gz' > $HOME/.makepkg.conf
	echo "PKGDEST='$tmpdir/workdir/pkgdest'" >> $HOME/.makepkg.conf
	mkdir -p "$tmpdir/workdir/pkgdest"
}

after() {
	_after
}

it_displays_usage_text() {
	rm -rf "$XDG_CONFIG_HOME"
	LANG=C librerelease -h >"$tmpdir/stdout" 2>"$tmpdir/stderr"

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

it_lists_all_files() {
	mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2"
	touch \
		"$WORKDIR/staging/repo1/file1" \
		"$WORKDIR/staging/repo1/file2" \
		"$WORKDIR/staging/repo2/file with spaces"
	LANG=C librerelease -l &>"$tmpdir/list"

	cat > "$tmpdir/list-correct" <<EOF
  -> repo1
file1
file2
  -> repo2
file with spaces
EOF

	diff "$tmpdir/list-correct" "$tmpdir/list"
	empty "$tmpdir/list"