1# -*- mode: shell-script -*-
2
3test_dir=$(dirname $0)
4source "$test_dir/setup.sh"
5
6oneTimeSetUp() {
7    rm -rf "$WORKON_HOME"
8    mkdir -p "$WORKON_HOME"
9    rm -rf "$PROJECT_HOME"
10    mkdir -p "$PROJECT_HOME"
11    source "$test_dir/../virtualenvwrapper.sh"
12}
13
14oneTimeTearDown() {
15    rm -rf "$WORKON_HOME"
16    rm -rf "$PROJECT_HOME"
17}
18
19setUp () {
20    echo
21}
22
23test_with_project () {
24    mkproject myproject >/dev/null 2>&1
25    cd $TMPDIR
26    cdproject
27    assertSame "$PROJECT_HOME/myproject" "$(pwd)"
28    deactivate
29}
30
31test_without_project () {
32    mkvirtualenv myproject >/dev/null 2>&1
33    cd $TMPDIR
34    output=$(cdproject 2>&1)
35    echo "$output" | grep -q "No project set"
36    RC=$?
37    assertSame "1" "$RC"
38    deactivate
39}
40
41test_space_in_path () {
42    (
43    set -e
44    PROJECT_HOME="$PROJECT_HOME/with spaces"
45    mkdir -p "$PROJECT_HOME"
46    mkproject "myproject" >/dev/null 2>&1
47    cd "$WORKON_HOME"
48    cdproject
49    test "$PROJECT_HOME/myproject" = "$PWD"
50    )
51    assertTrue "Did not cd to project directory" $?
52}
53
54
55. "$test_dir/shunit2"
56