2014-01-02 11:48:22 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
mkdir -p "$PYENV_TEST_DIR"
|
|
|
|
cd "$PYENV_TEST_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "invocation without 2 arguments prints usage" {
|
|
|
|
run pyenv-version-file-write
|
|
|
|
assert_failure "Usage: pyenv version-file-write <file> <version>"
|
|
|
|
run pyenv-version-file-write "one" ""
|
|
|
|
assert_failure
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "setting nonexistent version fails" {
|
|
|
|
assert [ ! -e ".python-version" ]
|
2014-01-02 14:38:29 -05:00
|
|
|
run pyenv-version-file-write ".python-version" "2.7.6"
|
|
|
|
assert_failure "pyenv: version \`2.7.6' not installed"
|
2014-01-02 11:48:22 -05:00
|
|
|
assert [ ! -e ".python-version" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "writes value to arbitrary file" {
|
2014-01-02 14:38:29 -05:00
|
|
|
mkdir -p "${PYENV_ROOT}/versions/2.7.6"
|
2014-01-02 11:48:22 -05:00
|
|
|
assert [ ! -e "my-version" ]
|
2014-01-02 14:38:29 -05:00
|
|
|
run pyenv-version-file-write "${PWD}/my-version" "2.7.6"
|
2014-01-02 11:48:22 -05:00
|
|
|
assert_success ""
|
2014-01-02 14:38:29 -05:00
|
|
|
assert [ "$(cat my-version)" = "2.7.6" ]
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|