pyenv/test/--version.bats
Yamashita, Yuu 30538b0672 Fix broken tests for pyenv---version
I need to use release date versioning at least for now until preparing
custom version comparator for brew's formula.
2016-03-04 00:31:04 +00:00

55 lines
1.1 KiB
Bash

#!/usr/bin/env bats
load test_helper
export GIT_DIR="${PYENV_TEST_DIR}/.git"
setup() {
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 20"* ]]
}
@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 20"* ]]
}
@test "reads version from git repo" {
git init
git remote add origin https://github.com/yyuu/pyenv.git
git_commit
git tag v20380119
git_commit
git_commit
run pyenv---version
assert_success "pyenv 20380119-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/yyuu/pyenv.git
git_commit
run pyenv---version
[[ $output == "pyenv 20"* ]]
}