File: version-file-write.bats

package info (click to toggle)
pyenv 2.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,176 kB
  • sloc: sh: 4,727; python: 402; makefile: 70; ansic: 60
file content (37 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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 [-f|--force] <file> <version> [...]"
  run pyenv-version-file-write "one" ""
  assert_failure
}

@test "setting nonexistent version fails" {
  assert [ ! -e ".python-version" ]
  run pyenv-version-file-write ".python-version" "2.7.6"
  assert_failure "pyenv: version \`2.7.6' not installed"
  assert [ ! -e ".python-version" ]
}

@test "setting nonexistent version succeeds with force" {
  assert [ ! -e ".python-version" ]
  run pyenv-version-file-write --force ".python-version" "2.7.6"
  assert_success
  assert [ -e ".python-version" ]
}

@test "writes value to arbitrary file" {
  mkdir -p "${PYENV_ROOT}/versions/2.7.6"
  assert [ ! -e "my-version" ]
  run pyenv-version-file-write "${PWD}/my-version" "2.7.6"
  assert_success ""
  assert [ "$(cat my-version)" = "2.7.6" ]
}