File: test_log_dir.sh~

package info (click to toggle)
virtualenvwrapper 3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,140 kB
  • sloc: sh: 3,801; python: 991; makefile: 27
file content (37 lines) | stat: -rw-r--r-- 997 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

#set -x

test_dir=$(cd $(dirname $0) && pwd)

export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"

setUp () {
    echo
}

test_set_by_user() {
    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs"
    mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR"
    source "$test_dir/../virtualenvwrapper.sh"
    assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]"
}

test_file_permissions() {
    export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs"
    mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR"
    source "$test_dir/../virtualenvwrapper.sh"
    perms=$(ls -l "$WORKON_HOME/logs/hook.log" | cut -f1 -d' ')
    #echo $perms
    assertTrue "Log file permissions are wrong: $perms" "echo $perms | grep '^-rw-rw'"
}

test_not_set_by_user() {
    unset WORKON_HOME
    unset VIRTUALENVWRAPPER_LOG_DIR
    unset VIRTUALENVWRAPPER_HOOK_DIR
    source "$test_dir/../virtualenvwrapper.sh"
    assertSame "$WORKON_HOME" "$VIRTUALENVWRAPPER_LOG_DIR"
}

. "$test_dir/shunit2"