Parent directory

test_is_valid_virtualenv.zunit

894 bytes
 1#!/usr/bin/env zunit
 2
 3
 4@setup {
 5    export DISABLE_AUTOSWITCH_VENV="1"
 6    load "../autoswitch_virtualenv.plugin.zsh"
 7    TARGET="$(mktemp -d)"
 8}
 9
10@teardown {
11    rm -rf "$TARGET"
12}
13
14@test '_is_valid_virtualenv - returns true for valid virtualenv' {
15    mkdir -p "$TARGET/.venv/bin"
16    touch "$TARGET/.venv/bin/activate"
17
18    run _is_valid_virtualenv "$TARGET/.venv"
19
20    assert $state equals 0
21}
22
23@test '_is_valid_virtualenv - returns false for directory without bin/activate' {
24    mkdir -p "$TARGET/.venv/bin"
25
26    run _is_valid_virtualenv "$TARGET/.venv"
27
28    assert $state equals 1
29}
30
31@test '_is_valid_virtualenv - returns false for non-existent path' {
32    run _is_valid_virtualenv "$TARGET/.venv"
33
34    assert $state equals 1
35}
36
37@test '_is_valid_virtualenv - returns false for file' {
38    touch "$TARGET/.venv"
39
40    run _is_valid_virtualenv "$TARGET/.venv"
41
42    assert $state equals 1
43}