Skip to content

Commit 07b31aa

Browse files
committed
Add tests for virtualenv-delete
1 parent 7e821de commit 07b31aa

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/delete.bats

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bats
2+
3+
load test_helper
4+
5+
setup() {
6+
export PYENV_ROOT="${TMP}/pyenv"
7+
}
8+
9+
@test "delete virtualenv" {
10+
mkdir -p "${PYENV_ROOT}/versions/venv27"
11+
12+
stub pyenv-virtualenv-prefix "venv27 : true"
13+
stub pyenv-rehash "true"
14+
15+
run pyenv-virtualenv-delete -f "venv27"
16+
17+
assert_success
18+
19+
unstub pyenv-virtualenv-prefix
20+
unstub pyenv-rehash
21+
22+
[ ! -d "${PYENV_ROOT}/versions/venv27" ]
23+
}
24+
25+
@test "delete virtualenv by symlink" {
26+
mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27"
27+
ln -fs "${PYENV_ROOT}/versions/2.7.10/envs/venv27" "${PYENV_ROOT}/versions/venv27"
28+
29+
stub pyenv-rehash "true"
30+
31+
run pyenv-virtualenv-delete -f "venv27"
32+
33+
assert_success
34+
35+
unstub pyenv-rehash
36+
37+
[ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ]
38+
[ ! -L "${PYENV_ROOT}/versions/venv27" ]
39+
}
40+
41+
@test "delete virtualenv with symlink" {
42+
mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27"
43+
ln -fs "${PYENV_ROOT}/versions/2.7.10/envs/venv27" "${PYENV_ROOT}/versions/venv27"
44+
45+
stub pyenv-rehash "true"
46+
47+
run pyenv-virtualenv-delete -f "2.7.10/envs/venv27"
48+
49+
assert_success
50+
51+
unstub pyenv-rehash
52+
53+
[ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ]
54+
[ ! -L "${PYENV_ROOT}/versions/venv27" ]
55+
}
56+
57+
@test "not delete virtualenv with same name" {
58+
mkdir -p "${PYENV_ROOT}/versions/2.7.10/envs/venv27"
59+
mkdir -p "${PYENV_ROOT}/versions/venv27"
60+
61+
stub pyenv-rehash "true"
62+
63+
run pyenv-virtualenv-delete -f "2.7.10/envs/venv27"
64+
65+
assert_success
66+
67+
unstub pyenv-rehash
68+
69+
[ ! -d "${PYENV_ROOT}/versions/2.7.10/envs/venv27" ]
70+
[ -d "${PYENV_ROOT}/versions/venv27" ]
71+
}

0 commit comments

Comments
 (0)