summaryrefslogtreecommitdiff
path: root/test/cases/librestage.bats
blob: 000ea3e319a348edceb5c7e20703c69eaf1be603 (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
50
51
52
53
54
55
56
57
58
59
load ../lib/common

shopt -s extglob

@test "librestage displays usage text" {
	rm -rf "$XDG_CONFIG_HOME"
	LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr

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

@test "librestage fails with 0 args" {
	librestage >$tmpdir/stdout 2>$tmpdir/stderr || status=$?

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

@test "librestage fails with invalid args" {
	librestage -q >$tmpdir/stdout 2>$tmpdir/stderr || status=$?

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

# bats test_tags=network,sudo
@test "librestage guesses the repo" {
	mkdir -p -- "$tmpdir/reponame/libretools-hello"
	cp fixtures/librestage/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD"
	cd "$tmpdir/reponame/libretools-hello"

	testsudo libremakepkg -l "$BATS_TEST_NAME"
	librestage

	find "$tmpdir" -not -type d -exec ls -ld -- {} +
	globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))
	globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
}

# bats test_tags=network,sudo
@test "librestage stages packages without PKGDEST" {
	cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
		PKGDEST=''
		SRCPKGDEST=''
		eot

	cp fixtures/librestage/PKGBUILD-hello "$tmpdir/PKGBUILD"
	cd "$tmpdir"

		testsudo libremakepkg -l "$BATS_TEST_NAME"
	librestage repo1

	find "$tmpdir" -not -type d -exec ls -ld -- {} +
	globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar?(.!(sig|*.*))
	globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar?(.!(sig|*.*))
}