1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-08 11:33:49 -05:00
Files
pyenv/test/--version.bats
rockandska 92a28e531b use BATS_FILE_TMPDIR in test/plugin test
use global setup with bats with possibility to add specific test file _setup
use readlink in helper if realpath is not working as expected
2025-09-15 19:48:34 +02:00

55 lines
1.1 KiB
Bash

#!/usr/bin/env bats
load test_helper
_setup() {
export GIT_DIR="${PYENV_TEST_DIR}/.git"
mkdir -p "$HOME"
git config --global user.name "Tester"
git config --global user.email "tester@test.local"
cd "$PYENV_TEST_DIR"
}
git_commit() {
git commit --quiet --allow-empty -m "empty"
}
@test "default version" {
assert [ ! -e "$PYENV_ROOT" ]
run pyenv---version
assert_success
[[ $output == "pyenv "?.?.* ]]
}
@test "doesn't read version from non-pyenv repo" {
git init
git remote add origin https://github.com/homebrew/homebrew.git
git_commit
git tag v1.0
run pyenv---version
assert_success
[[ $output == "pyenv "?.?.* ]]
}
@test "reads version from git repo" {
git init
git remote add origin https://github.com/pyenv/pyenv.git
git_commit
git tag v0.4.1
git_commit
git_commit
run pyenv---version
assert_success "pyenv 0.4.1-2-g$(git rev-parse --short HEAD)"
}
@test "prints default version if no tags in git repo" {
git init
git remote add origin https://github.com/pyenv/pyenv.git
git_commit
run pyenv---version
[[ $output == "pyenv "?.?.* ]]
}