forked from netbox-community/netbox-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·46 lines (35 loc) · 1019 Bytes
/
test.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
#!/bin/bash
# exit when a command exits with an exit code != 0
set -e
# version is used by `docker-compose.yml` do determine the tag
# of the Docker Image that is to be used
export VERSION=${VERSION-latest}
test_netbox_unit_tests() {
echo "⏱ Running Netbox Unit Tests"
docker-compose run --rm netbox ./manage.py test
}
test_initializers() {
echo "🏗 Testing Initializers"
mkdir initializers_test
(
cd initializers
for script in *.yml; do
sed -E 's/^# //' "${script}" > "../initializers_test/${script}"
done
)
mv initializers initializers_original
mv initializers_test initializers
docker-compose run --rm netbox ./manage.py check
}
test_cleanup() {
echo "💣 Cleaning Up"
docker-compose down -v
rm -rf initializers
mv initializers_original initializers
}
echo "🐳🐳🐳 Start testing '${VERSION}'"
# Make sure the cleanup script is executed
trap test_cleanup EXIT ERR
test_netbox_unit_tests
test_initializers
echo "🐳🐳🐳 Done testing '${VERSION}'"