3d42e41a33d9a5465e9dfebb2a3e4172e9a7ef1b

Author
Michael Aquilina <michaelaquilina@gmail.com>
Committer
Michael Aquilina <michaelaquilina@gmail.com>
Date

Message

Add initial check_venv tests

Diff

 1diff --git a/tests/test_check_venv_path.zunit b/tests/test_check_venv_path.zunit
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..0e208e15d306ee87057da3b1f0ac384c6d97cdc0
 4--- /dev/null
 5+++ b/tests/test_check_venv_path.zunit
 6@@ -0,0 +1,45 @@
 7+#!/usr/bin/env zunit
 8+
 9+
10+@setup {
11+    export DISABLE_AUTOSWITCH_VENV="1"
12+    load "../autoswitch_virtualenv.plugin.zsh"
13+    TARGET="$(mktemp -d)"
14+}
15+
16+@teardown {
17+    rm -rf "$TARGET"
18+}
19+
20+@test 'test finds in base directory' {
21+    touch "$TARGET/.venv"
22+
23+    run _check_venv_path "$TARGET"
24+
25+    assert $state equals 0
26+    assert "$output" same_as "$TARGET/.venv"
27+}
28+
29+@test 'returns nothing if not found' {
30+   run _check_venv_path "$TARGET"
31+
32+   assert $state equals 0
33+   assert "$output" is_empty
34+}
35+
36+@test 'finds .venv in parent directories' {
37+    touch "$TARGET/.venv"
38+    mkdir "$TARGET/foo"
39+
40+    run _check_venv_path "$TARGET/foo"
41+
42+    assert $state equals 0
43+    assert "$output" same_as "$TARGET/.venv"
44+}
45+
46+@test 'returns nothing with root path' {
47+    run _check_venv_path '/'
48+
49+    assert $state equals 0
50+    assert "$output" is_empty
51+}