File: --version.bats

package info (click to toggle)
pyenv 2.6.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,496 kB
  • sloc: sh: 4,914; python: 410; makefile: 161; ansic: 60
file content (54 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bats

load test_helper

_setup() {
  export GIT_DIR="${PYENV_TEST_DIR}/.git"
  mkdir -p "$HOME"
  git config --global user.name  "Tester"
  git config --global user.email "tester@test.local"
  cd "$PYENV_TEST_DIR"
}

git_commit() {
  git commit --quiet --allow-empty -m "empty"
}

@test "default version" {
  assert [ ! -e "$PYENV_ROOT" ]
  run pyenv---version
  assert_success
  [[ $output == "pyenv "?.?.* ]]
}

@test "doesn't read version from non-pyenv repo" {
  git init
  git remote add origin https://github.com/homebrew/homebrew.git
  git_commit
  git tag v1.0

  run pyenv---version
  assert_success
  [[ $output == "pyenv "?.?.* ]]
}

@test "reads version from git repo" {
  git init
  git remote add origin https://github.com/pyenv/pyenv.git
  git_commit
  git tag v0.4.1
  git_commit
  git_commit

  run pyenv---version
  assert_success "pyenv 0.4.1-2-g$(git rev-parse --short HEAD)"
}

@test "prints default version if no tags in git repo" {
  git init
  git remote add origin https://github.com/pyenv/pyenv.git
  git_commit

  run pyenv---version
  [[ $output == "pyenv "?.?.* ]]
}