a48a21d8c95bf4e59ad40372e8fe7727ca854b18
- Author
- Michael Aquilina <michaelaquilina@gmail.com>
- Committer
- Michael Aquilina <michaelaquilina@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/tests/test_mkvenv.zunit b/tests/test_mkvenv.zunit
2index 7af9626ad387f577f52f860b9827dd745cd02dd8..ae18ab4ebb5a6d1d080f9e5133fb717ccf9b63a4 100644
3--- a/tests/test_mkvenv.zunit
4+++ b/tests/test_mkvenv.zunit
5@@ -10,6 +10,22 @@
6 unset AUTOSWITCH_DEFAULT_REQUIREMENTS
7 TARGET="$(mktemp -d)"
8 cd "$TARGET"
9+
10+ function poetry {
11+ echo "poetry" $@
12+ }
13+
14+ function _activate_poetry {
15+ echo "activating poetry"
16+ }
17+
18+ function pipenv {
19+ echo "pipenv" $@
20+ }
21+
22+ function _activate_pipenv {
23+ echo "activating pipenv"
24+ }
25 }
26
27 @teardown {
28@@ -42,6 +58,30 @@
29 assert "$output" same_as "myproject"
30 }
31
32+@test 'mkvenv - (poetry project) runs correct command' {
33+ mkdir myproject
34+ cd myproject
35+ touch "poetry.lock"
36+
37+ run mkvenv
38+
39+ assert $status equals 0
40+ assert "$lines[1]" same_as "poetry install"
41+ assert "$lines[2]" same_as "activating poetry"
42+}
43+
44+@test 'mkvenv - (pipenv project) runs correct command' {
45+ mkdir myproject
46+ cd myproject
47+ touch "Pipfile"
48+
49+ run mkvenv
50+
51+ assert $status equals 0
52+ assert "$lines[1]" same_as "pipenv install --dev"
53+ assert "$lines[2]" same_as "activating pipenv"
54+}
55+
56 @test 'mkvenv - uses default python if set and not specified' {
57 mkdir myproject
58 cd myproject
59@@ -102,3 +142,47 @@
60 assert "$lines[5]" is_empty
61 assert ${#lines} equals 4
62 }
63+
64+@test 'prints help message and disables plugin if poetry not setup' {
65+ touch "poetry.lock"
66+
67+ # Mock type to fail
68+ function type() {
69+ if [[ "$1" == "poetry" ]]; then
70+ return 1
71+ fi
72+ return 0
73+ }
74+
75+ run mkvenv
76+
77+ assert $status equals 0
78+ assert "$lines[1]" contains "zsh-autoswitch-virtualenv requires 'poetry' to install this project!"
79+ assert "$lines[2]" is_empty
80+ assert "$lines[3]" contains "If this is already installed but you are still seeing this message,"
81+ assert "$lines[4]" contains "then make sure the \e[1mpoetry\e[0m command is in your PATH.\n"
82+ assert "$lines[5]" is_empty
83+ assert ${#lines} equals 4
84+}
85+
86+@test 'prints help message and disables plugin if pipenv not setup' {
87+ touch "Pipfile"
88+
89+ # Mock type to fail
90+ function type() {
91+ if [[ "$1" == "pipenv" ]]; then
92+ return 1
93+ fi
94+ return 0
95+ }
96+
97+ run mkvenv
98+
99+ assert $status equals 0
100+ assert "$lines[1]" contains "zsh-autoswitch-virtualenv requires 'pipenv' to install this project!"
101+ assert "$lines[2]" is_empty
102+ assert "$lines[3]" contains "If this is already installed but you are still seeing this message,"
103+ assert "$lines[4]" contains "then make sure the \e[1mpipenv\e[0m command is in your PATH.\n"
104+ assert "$lines[5]" is_empty
105diff --git a/tests/test_rmvenv.zunit b/tests/test_rmvenv.zunit
106index 0e1b51df1ebc7c34fce96e0212e4824a95a496b8..c7fde66c80f7d479c6d00ed5db0c1e0c74598efc 100644
107--- a/tests/test_rmvenv.zunit
108+++ b/tests/test_rmvenv.zunit
109@@ -7,6 +7,18 @@
110 unset AUTOSWITCH_DEFAULT_REQUIREMENTS
111 TARGET="$(mktemp -d)"
112 cd "$TARGET"
113+
114+ function poetry {
115+ echo 'poetry' $@
116+ }
117+
118+ function pipenv {
119+ echo 'pipenv' $@
120+ }
121+
122+ function deactivate {
123+ echo 'deactivate'
124+ }
125 }
126
127 @teardown {
128@@ -64,3 +76,24 @@
129 test ! -f .venv
130 test ! -d "$HOME/.virtualenvs/$test_venv"
131 }
132+
133+@test 'rmvenv - uninstalls poetry project' {
134+ touch "poetry.lock"
135+
136+ run rmvenv
137+
138+ assert $state equals 0
139+ assert "$lines[1]" same_as "deactivate"
140+ assert "$lines[2]" same_as "poetry env remove poetry run which python"
141+}
142+
143+
144+@test 'rmvenv - uninstalls pipenv project' {
145+ touch "Pipfile"
146+
147+ run rmvenv
148+
149+ assert $state equals 0
150+ assert "$lines[1]" same_as "deactivate"
151+ assert "$lines[2]" same_as "pipenv --rm"
152+}