forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dc-unittest.sh
executable file
·76 lines (69 loc) · 1.59 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
unset PROFILE
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 " --profile -p {DOCKER_PROFILE_NAME}"
echo " --test-case -t {YOUR_FULLY_QUALIFIED_TEST_CASE}"
echo
echo " --help -h - prints this dialogue."
echo
echo "Environment Variables:"
echo " DD_PROFILE={DOCKER_PROFILE_NAME}"
echo
echo "You must specify a test case (arg) and profile (arg or env var)!"
echo
echo "Example command:"
echo "./dc-unittest.sh --profile mysql-rabbitmq --test-case unittests.tools.test_stackhawk_parser.TestStackHawkParser"
}
while [[ $# -gt 0 ]]; do
case $1 in
-p|--profile)
PROFILE="$2"
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 $PROFILE ]
then
if [ -z $DD_PROFILE ]
then
echo "No profile supplied."
usage
exit 1
else
PROFILE=$DD_PROFILE
fi
fi
if [ -z $TEST_CASE ]
then
echo "No test case supplied."
usage
exit 1
fi
echo "Running docker compose unit tests with profile $PROFILE and test case $TEST_CASE ..."
docker-compose --profile $PROFILE --env-file ./docker/environments/$PROFILE.env exec uwsgi bash -c "python manage.py test $TEST_CASE -v2"