2014-01-02 16:48:22 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
mkdir -p "${PYENV_TEST_DIR}/myproject"
|
|
|
|
cd "${PYENV_TEST_DIR}/myproject"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fails without arguments" {
|
|
|
|
run pyenv-version-file-read
|
|
|
|
assert_failure ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fails for invalid file" {
|
|
|
|
run pyenv-version-file-read "non-existent"
|
|
|
|
assert_failure ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "fails for blank file" {
|
|
|
|
echo > my-version
|
|
|
|
run pyenv-version-file-read my-version
|
|
|
|
assert_failure ""
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "reads simple version file" {
|
2014-01-02 19:38:29 +00:00
|
|
|
cat > my-version <<<"3.3.3"
|
2014-01-02 16:48:22 +00:00
|
|
|
run pyenv-version-file-read my-version
|
2014-01-02 19:38:29 +00:00
|
|
|
assert_success "3.3.3"
|
2014-01-02 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "ignores leading spaces" {
|
2014-01-02 19:38:29 +00:00
|
|
|
cat > my-version <<<" 3.3.3"
|
2014-01-02 16:48:22 +00:00
|
|
|
run pyenv-version-file-read my-version
|
2014-01-02 19:38:29 +00:00
|
|
|
assert_success "3.3.3"
|
2014-01-02 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "reads only the first word from file" {
|
2014-01-02 19:38:29 +00:00
|
|
|
cat > my-version <<<"3.3.3-p194@tag 2.7.6 hi"
|
2014-01-02 16:48:22 +00:00
|
|
|
run pyenv-version-file-read my-version
|
2014-01-02 19:38:29 +00:00
|
|
|
assert_success "3.3.3-p194@tag:2.7.6:hi"
|
2014-01-02 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "loads only the first line in file" {
|
|
|
|
cat > my-version <<IN
|
2014-01-02 19:38:29 +00:00
|
|
|
2.7.6 one
|
|
|
|
3.3.3 two
|
2014-01-02 16:48:22 +00:00
|
|
|
IN
|
|
|
|
run pyenv-version-file-read my-version
|
2014-01-02 19:38:29 +00:00
|
|
|
assert_success "2.7.6:one:3.3.3:two"
|
2014-01-02 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "ignores leading blank lines" {
|
|
|
|
cat > my-version <<IN
|
|
|
|
|
2014-01-02 19:38:29 +00:00
|
|
|
3.3.3
|
2014-01-02 16:48:22 +00:00
|
|
|
IN
|
|
|
|
run pyenv-version-file-read my-version
|
2014-01-02 19:38:29 +00:00
|
|
|
assert_success "3.3.3"
|
2014-01-02 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "handles the file with no trailing newline" {
|
2014-01-02 19:38:29 +00:00
|
|
|
echo -n "2.7.6" > my-version
|
2014-01-02 16:48:22 +00:00
|
|
|
run pyenv-version-file-read my-version
|
2014-01-02 19:38:29 +00:00
|
|
|
assert_success "2.7.6"
|
2014-01-02 16:48:22 +00:00
|
|
|
}
|