forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-unittest.sh
More file actions
executable file
·69 lines (63 loc) · 2.04 KB
/
run-unittest.sh
File metadata and controls
executable file
·69 lines (63 loc) · 2.04 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
unset TEST_CASE
unset FAIL_FAST
bash ./docker/docker-compose-check.sh
if [[ $? -eq 1 ]]; then exit 1; fi
usage() {
echo
echo "This script helps with running unit tests."
echo
echo "Options:"
echo " --test-case -t {YOUR_FULLY_QUALIFIED_TEST_CASE}"
echo " --fail-fast -f - stop on first test failure"
echo " --help -h - prints this dialogue."
echo
echo "You must specify a test case (arg)!"
echo "Any additional arguments will be passed to the test command."
echo
echo "Make sure you run this script in dev mode."
echo "You can enter dev mode using the following command:"
echo "./docker/setEnv.sh dev"
echo
echo "Lastly, make sure the application is running by using the following docker commands:"
echo "docker compose build"
echo "docker compose up"
echo
echo "Example commands:"
echo "./run-unittest.sh --test-case unittests.tools.test_stackhawk_parser.TestStackHawkParser"
echo "./run-unittest.sh --test-case unittests.tools.test_stackhawk_parser.TestStackHawkParser -v3 --failfast"
}
while [[ $# -gt 0 ]]; do
case $1 in
-t|--test-case)
TEST_CASE="$2"
shift # past argument
shift # past value
;;
-f|--fail-fast)
FAIL_FAST="--failfast"
shift # past argument
;;
-h|--help)
usage
exit 0
;;
*)
EXTRA_ARGS+=("$1") # save extra arg
shift # past argument
;;
esac
done
if [ -z "$TEST_CASE" ]
then
echo "No test case supplied."
usage
exit 1
fi
# docker compose exec uwsgi bash -c "python manage.py migrate dojo 0233"
# docker compose exec uwsgi bash -c "python manage.py migrate dojo 0234"
echo "Running docker compose unit tests with test case $TEST_CASE ..."
# Compose V2 integrates compose functions into the Docker platform, continuing to support
# most of the previous docker-compose features and flags. You can run Compose V2 by
# replacing the hyphen (-) with a space, using docker compose, instead of docker-compose.
docker compose exec uwsgi bash -c "python manage.py test $TEST_CASE -v2 --keepdb $FAIL_FAST"