2014-01-02 11:48:22 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
2016-03-01 20:39:52 -05:00
|
|
|
export GIT_DIR="${PYENV_TEST_DIR}/.git"
|
2015-12-23 21:52:33 -05:00
|
|
|
|
2014-01-02 11:48:22 -05:00
|
|
|
setup() {
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
git config --global user.name "Tester"
|
|
|
|
git config --global user.email "tester@test.local"
|
2016-03-01 20:39:52 -05:00
|
|
|
cd "$PYENV_TEST_DIR"
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
git_commit() {
|
|
|
|
git commit --quiet --allow-empty -m "empty"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "default version" {
|
|
|
|
assert [ ! -e "$PYENV_ROOT" ]
|
|
|
|
run pyenv---version
|
|
|
|
assert_success
|
2016-08-15 04:24:39 -04:00
|
|
|
[[ $output == "pyenv "?.?.? ]]
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|
|
|
|
|
2015-11-20 23:13:52 -05:00
|
|
|
@test "doesn't read version from non-pyenv repo" {
|
2015-10-25 11:54:38 -04:00
|
|
|
git init
|
|
|
|
git remote add origin https://github.com/homebrew/homebrew.git
|
|
|
|
git_commit
|
|
|
|
git tag v1.0
|
|
|
|
|
2015-11-20 23:13:52 -05:00
|
|
|
run pyenv---version
|
2015-10-25 11:54:38 -04:00
|
|
|
assert_success
|
2016-08-15 04:24:39 -04:00
|
|
|
[[ $output == "pyenv "?.?.? ]]
|
2015-10-25 11:54:38 -04:00
|
|
|
}
|
|
|
|
|
2014-01-02 11:48:22 -05:00
|
|
|
@test "reads version from git repo" {
|
|
|
|
git init
|
2017-03-05 23:31:25 -05:00
|
|
|
git remote add origin https://github.com/pyenv/pyenv.git
|
2014-01-02 11:48:22 -05:00
|
|
|
git_commit
|
2016-08-15 04:24:39 -04:00
|
|
|
git tag v0.4.1
|
2014-01-02 11:48:22 -05:00
|
|
|
git_commit
|
|
|
|
git_commit
|
|
|
|
|
|
|
|
run pyenv---version
|
2016-08-15 04:24:39 -04:00
|
|
|
assert_success "pyenv 0.4.1-2-g$(git rev-parse --short HEAD)"
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "prints default version if no tags in git repo" {
|
|
|
|
git init
|
2017-03-05 23:31:25 -05:00
|
|
|
git remote add origin https://github.com/pyenv/pyenv.git
|
2014-01-02 11:48:22 -05:00
|
|
|
git_commit
|
|
|
|
|
|
|
|
run pyenv---version
|
2016-08-15 04:24:39 -04:00
|
|
|
[[ $output == "pyenv "?.?.? ]]
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|