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

describe lib/conf.sh
. ./test-common.sh

it_sets_makepkg_vars_in_custom_file() {
	unset PKGDEST
	touch "$tmpdir/makepkg.conf"
	. $(librelib conf.sh)
	MAKEPKG_CONF="$tmpdir/makepkg.conf" set_var makepkg PKGDEST /pkgdest
	.  "$tmpdir/makepkg.conf"
	[[ $PKGDEST == /pkgdest ]]
}

it_figures_out_HOME_when_root() {
	require sudo || return 0
	# This one is tricky, because it does the job too well, it will find
	# the actual HOME, instead of the test environment HOME.  Therefore, we
	# will just check that [[ $HOME != /root ]]
	cd "$tmpdir"
	echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh
	LIBREHOME=$(testsudo bash ./test.sh)
	[[ $LIBREHOME != /root ]]
}

it_respects_custom_HOME() {
	cd "$tmpdir"
	echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh

	export HOME=/foo
	LIBREHOME=$(bash ./test.sh)

	[[ $LIBREHOME == /foo ]]
}