pyenv-binary-package: refactor tests

* make them more human-readable
* don't double-test external code outside of integration tests
This commit is contained in:
Ivan Pozdeev 2026-08-10 20:31:00 +03:00
parent f9ffb73a7e
commit 9962f8cb39

View file

@ -24,17 +24,15 @@ stub_build_environment() {
done
}
@test "completion lists the option and definitions provided by another plugin" {
mkdir -p "${PYENV_ROOT}/plugins/example/share/python-build"
touch "${PYENV_ROOT}/plugins/example/share/python-build/3.12.7-example"
PATH="${BATS_TEST_DIRNAME}/../../python-build/bin:${PATH}"
@test "completions" {
create_stub pyenv-install 'echo "${0##*/} $*"'
run pyenv-binary-package --complete
assert_success
assert_line "--archive-base-url"
assert_line "--verbose"
assert_line "3.12.7-example"
refute_line "Available versions:"
assert_success <<!
--archive-base-url
--verbose
pyenv-install --list --bare
!
}
@test "fails with no arguments" {
@ -89,7 +87,7 @@ stub_build_environment() {
assert_failure "pyenv-binary: macOS archives are not supported yet"
}
@test "writes the archive, metadata and definition under the entry name" {
@test "writes the archive, metadata and definition under the entry name (integration)" {
stub_build_environment
cd "${BATS_TEST_TMPDIR}"
@ -103,12 +101,24 @@ stub_build_environment() {
assert_success "ARCHIVE_URL=http://example.com/binaries/3.12.7-test.tar.gz"
}
@test "strips a trailing slash from the archive base url" {
@test "correctly joins archive base url with a trailing slash" {
stub_build_environment
create_stub pyenv-binary-save true
create_stub pyenv-binary-generate-installer <<'!'
echo -n "${0##*/} "
while (($#)); do
case $1 in
--archive-url)
echo "$1 ${2:?}"
break
;;
esac
shift
done
!
run pyenv-binary-package 3.12.7:3.12.7-test \
--archive-base-url http://example.com/binaries/
assert_success
run grep '^ARCHIVE_URL=' "${BATS_TEST_TMPDIR}/3.12.7-test"
assert_success "ARCHIVE_URL=http://example.com/binaries/3.12.7-test.tar.gz"
assert_line "pyenv-binary-generate-installer --archive-url http://example.com/binaries/3.12.7-test.tar.gz"
}