Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
install,fetch,rquery,upgrade: add tests for -r
Baptiste Daroussin committed 20 days ago
commit 77d3d8dfe131ddf9a767658dff4db61e89f40801
parent 74fc549
4 files changed +149 -3
modified tests/frontend/fetch.sh
@@ -17,7 +17,8 @@ tests_init \
	fetch_missing \
	fetch_missing_dep \
	fetch_missing_file \
-
	fetch_missing_dep_file
+
	fetch_missing_dep_file \
+
	fetch_disabled_repo

test_setup()
{
@@ -148,3 +149,49 @@ fetch_missing_dep_file_body()
		pkg -C "${CONF}/pkg.conf" fetch -r test -d -y test
}

+
# Verify that "pkg fetch -r <repo>" works on a disabled repository.
+
fetch_disabled_repo_body()
+
{
+
	atf_check rm -rf ${TEST_ROOT}/*
+
	atf_check mkdir -p ${CONF} ${REPOS} ${REPO} ${DB} ${CACHE} ${WORK}
+

+
	cat > ${CONF}/pkg.conf << EOF
+
PKG_CACHEDIR=${CACHE}
+
PKG_DBDIR=${DB}
+
REPOS_DIR=[
+
	${REPOS}
+
]
+
EOF
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg ${WORK}/test test 1 /usr/local
+
	atf_check \
+
		-o ignore \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -C "${CONF}/pkg.conf" create -o ${REPO} -M ${WORK}/test.ucl
+

+
	atf_check \
+
		-o ignore \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -C "${CONF}/pkg.conf" repo ${REPO}
+

+
	cat << EOF > ${REPOS}/disabled.conf
+
disabled_repo: {
+
	url: file:///${REPO},
+
	enabled: no
+
}
+
EOF
+

+
	atf_check \
+
		-o match:"Updating disabled_repo" \
+
		-s exit:0 \
+
		pkg -C "${CONF}/pkg.conf" update -r disabled_repo
+

+
	atf_check \
+
		-o ignore \
+
		-e empty \
+
		-s exit:0 \
+
		pkg -C "${CONF}/pkg.conf" fetch -U -r disabled_repo -y test
+
}
+

modified tests/frontend/install.sh
@@ -16,7 +16,8 @@ tests_init \
	install_suggest_set_automatic \
	install_no_suggest_when_flag_matches \
	install_from_url \
-
	install_automatic_flag_not_on_upgrade
+
	install_automatic_flag_not_on_upgrade \
+
	install_disabled_repo

test_setup()
{
@@ -583,3 +584,32 @@ EOF

	atf_check -s exit:0 pkg info -e test
}
+

+
# Verify that "pkg install -r <repo>" works on a disabled repository.
+
install_disabled_repo_body()
+
{
+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1" "${TMPDIR}"
+
	atf_check pkg create -M test.ucl
+
	atf_check -o ignore pkg repo .
+

+
	mkdir repos
+
	cat <<EOF > repos/myrepo.conf
+
myrepo: {
+
	url: "file://${TMPDIR}",
+
	enabled: no
+
}
+
EOF
+

+
	atf_check \
+
		-o match:"Updating myrepo" \
+
		-s exit:0 \
+
		pkg -R repos update -r myrepo
+

+
	atf_check \
+
		-o match:"Installing test" \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR="${TMPDIR}/repos" -o PKG_CACHEDIR="${TMPDIR}" \
+
		install -y -r myrepo test
+

+
	atf_check -s exit:0 pkg info -e test
+
}
modified tests/frontend/rquery.sh
@@ -20,7 +20,8 @@ tests_init \
	rquery_no_repo \
	rquery_not_found \
	rquery_multiple_pkgs \
-
	rquery_multi_repo
+
	rquery_multi_repo \
+
	rquery_disabled_repo

# Helper: set up a local file:// repo with rich packages
setup_repo() {
@@ -435,3 +436,30 @@ EOF
		pkg -o REPOS_DIR="${TMPDIR}/reposconf" \
		rquery -Ur repoB -a "%n"
}
+

+
# Verify that "rquery -r <repo>" works on a disabled repository.
+
rquery_disabled_repo_body() {
+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1.0" "/usr/local"
+
	atf_check pkg create -o ${TMPDIR}/repo -M test.ucl
+
	atf_check -o ignore pkg repo ${TMPDIR}/repo
+

+
	mkdir -p ${TMPDIR}/reposconf
+
	cat << EOF > ${TMPDIR}/reposconf/disabled.conf
+
disabled_repo: {
+
	url: file://${TMPDIR}/repo,
+
	enabled: no
+
}
+
EOF
+

+
	atf_check \
+
		-o match:"Updating disabled_repo" \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR="${TMPDIR}/reposconf" \
+
		update -r disabled_repo
+

+
	atf_check \
+
		-o inline:"test\n" \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR="${TMPDIR}/reposconf" \
+
		rquery -Ur disabled_repo -a "%n"
+
}
modified tests/frontend/upgrade.sh
@@ -22,6 +22,7 @@ tests_init \
	symlink_to_dir_upgrade \
	newpkgversion_two_repos \
	upgrade_disabled_repo \
+
	upgrade_all_disabled_repos \

issue1881_body() {
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg pkg1 pkg_a 1
@@ -842,3 +843,43 @@ EOF
		-o inline:"2\n" \
		pkg query "%v" test
}
+

+
# Verify that "pkg upgrade -r <repo>" works when ALL repositories are disabled.
+
upgrade_all_disabled_repos_body()
+
{
+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "1"
+
	atf_check -o ignore pkg register -M test.ucl
+

+
	atf_check sh ${RESOURCEDIR}/test_subr.sh new_pkg "test" "test" "2"
+
	atf_check pkg create -M test.ucl
+
	atf_check -o ignore pkg repo .
+

+
	mkdir repos
+
	cat <<EOF > repos/repo1.conf
+
repo1: {
+
	url: "file://${TMPDIR}",
+
	enabled: no
+
}
+
EOF
+
	cat <<EOF > repos/repo2.conf
+
repo2: {
+
	url: "file://${TMPDIR}",
+
	enabled: no
+
}
+
EOF
+

+
	atf_check \
+
		-o match:"Updating repo1" \
+
		-s exit:0 \
+
		pkg -R repos update -r repo1
+

+
	atf_check \
+
		-o match:"Upgrading test from 1 to 2" \
+
		-s exit:0 \
+
		pkg -o REPOS_DIR="${TMPDIR}/repos" -o PKG_CACHEDIR="${TMPDIR}" \
+
		upgrade -y -r repo1
+

+
	atf_check \
+
		-o inline:"2\n" \
+
		pkg query "%v" test
+
}