File tree Expand file tree Collapse file tree 2 files changed +49
-10
lines changed Expand file tree Collapse file tree 2 files changed +49
-10
lines changed Original file line number Diff line number Diff line change 2
2
3
3
. hooks/common
4
4
5
- run_test () {
6
- echo " π³π³π³ Testing '${1} '"
7
- VERSION=" ${1} " docker-compose run netbox ./manage.py test
8
- docker-compose down -v
9
- echo " π³π³π³ Done testing '${1} '"
10
- }
11
-
12
5
# test on builds of 'branches'
13
6
if [ " ${BUILD} " == " branches" ] \
14
7
|| [ " ${DEBUG} " == " true" ]; then
15
- run_test latest
16
- run_test snapshot
8
+ ./test.sh latest
9
+ ./test.sh snapshot
17
10
# test on bulds of 'this' (i.e. pull request)
18
11
elif [ " ${BUILD} " == " this" ]; then
19
- run_test latest
12
+ ./test.sh latest
20
13
else
21
14
echo " π³π³π³ No tests are implemented for build '${BUILD} '."
22
15
fi
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # exit when a command exits with an exit code != 0
4
+ set -e
5
+
6
+ # version is used by `docker-compose.yml` do determine the tag
7
+ # of the Docker Image that is to be used
8
+ export VERSION=${VERSION-latest}
9
+
10
+ test_netbox_unit_tests () {
11
+ echo " β± Running Netbox Unit Tests"
12
+ docker-compose run --rm netbox ./manage.py test
13
+ }
14
+
15
+ test_initializers () {
16
+ echo " π Testing Initializers"
17
+
18
+ mkdir initializers_test
19
+ (
20
+ cd initializers
21
+ for script in * .yml; do
22
+ sed -E ' s/^# //' " ${script} " > " ../initializers_test/${script} "
23
+ done
24
+ )
25
+ mv initializers initializers_original
26
+ mv initializers_test initializers
27
+
28
+ docker-compose run --rm netbox ./manage.py check
29
+ }
30
+
31
+ test_cleanup () {
32
+ echo " π£ Cleaning Up"
33
+ docker-compose down -v
34
+ rm -rf initializers
35
+ mv initializers_original initializers
36
+ }
37
+
38
+ echo " π³π³π³ Start testing '${VERSION} '"
39
+
40
+ # Make sure the cleanup script is executed
41
+ trap test_cleanup EXIT ERR
42
+
43
+ test_netbox_unit_tests
44
+ test_initializers
45
+
46
+ echo " π³π³π³ Done testing '${VERSION} '"
You canβt perform that action at this time.
0 commit comments