forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc-unittest.sh
executable file
·62 lines (55 loc) · 1.47 KB
/
dc-unittest.sh
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
#!/usr/bin/env bash
unset TEST_CASE
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 " --help -h - prints this dialogue."
echo
echo "You must specify a test case (arg)!"
echo
echo "Example command:"
echo "./dc-unittest.sh --test-case unittests.tools.test_stackhawk_parser.TestStackHawkParser"
}
while [[ $# -gt 0 ]]; do
case $1 in
-p|--profile)
# Leaving this here for backwards compatability
shift # past argument
shift # past value
;;
-t|--test-case)
TEST_CASE="$2"
shift # past argument
shift # past value
;;
-h|--help)
usage
exit 0
;;
-*)
echo "Unknown option $1"
usage
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
if [ -z "$TEST_CASE" ]
then
echo "No test case supplied."
usage
exit 1
fi
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"