mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
66 lines
1.3 KiB
Bash
66 lines
1.3 KiB
Bash
#!/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" {
|
|
cat > my-version <<<"1.9.3"
|
|
run pyenv-version-file-read my-version
|
|
assert_success "1.9.3"
|
|
}
|
|
|
|
@test "ignores leading spaces" {
|
|
cat > my-version <<<" 1.9.3"
|
|
run pyenv-version-file-read my-version
|
|
assert_success "1.9.3"
|
|
}
|
|
|
|
@test "reads only the first word from file" {
|
|
cat > my-version <<<"1.9.3-p194@tag 1.8.7 hi"
|
|
run pyenv-version-file-read my-version
|
|
assert_success "1.9.3-p194@tag:1.8.7:hi"
|
|
}
|
|
|
|
@test "loads only the first line in file" {
|
|
cat > my-version <<IN
|
|
1.8.7 one
|
|
1.9.3 two
|
|
IN
|
|
run pyenv-version-file-read my-version
|
|
assert_success "1.8.7:one:1.9.3:two"
|
|
}
|
|
|
|
@test "ignores leading blank lines" {
|
|
cat > my-version <<IN
|
|
|
|
1.9.3
|
|
IN
|
|
run pyenv-version-file-read my-version
|
|
assert_success "1.9.3"
|
|
}
|
|
|
|
@test "handles the file with no trailing newline" {
|
|
echo -n "1.8.7" > my-version
|
|
run pyenv-version-file-read my-version
|
|
assert_success "1.8.7"
|
|
}
|