Fix bootstrap test.
[fnp-django-template.git] / tests / test_bootstrap.sh
1 #!/bin/bash
2 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 # Colorful output.
4 strong='\e[0;32m'
5 error='\e[1;31m'
6 normal='\e[0m'
7
8 tmpdir="`mktemp -d "$DIR/test-XXX"`"
9 echo "$tmpdir"
10
11
12 export WORKON_HOME="$tmpdir/v"
13 mkdir "$WORKON_HOME"
14
15
16 PYTHON="$1"
17 if [ -z "$PYTHON" ]; then
18   PYTHON=python
19 fi
20 PYTHON_VER="`$PYTHON -V 2>&1`"
21 echo -e "${strong}Using $PYTHON_VER${normal}"
22 PYTHON="`which $PYTHON`"
23
24 FNP_PROJECT_TEMPLATE="$DIR"/../src
25 projectdir="$tmpdir"/p
26 mkdir "$projectdir"
27 cd "$projectdir"
28
29 PROJECT=TEST_PROJECT
30
31 . "$DIR"/../bootstrap.sh
32
33
34 # Test for active virtualenv
35 if [ "$VIRTUAL_ENV" != "$WORKON_HOME/TEST_PROJECT" ]; then
36     echo -e "${error}Expected to be in virtualenv, found python: `which python`${normal}"
37 fi
38 if [ "`python -V 2>&1`" != "$PYTHON_VER" ]; then
39     echo -e "${error}Expected $PYTHON_VER, found `python -V 2>&1`${normal}"
40 fi
41
42 # Test that there is only project dir in the dir.
43 if [ "`ls "$projectdir"`" != "TEST_PROJECT" ]; then
44     echo -e "${error}Only created project expected in project dir, found: `ls "$projectdir"`${normal}"
45 fi
46
47 rm -rf "$tmpdir"