-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest-docker.sh
executable file
·61 lines (48 loc) · 1.33 KB
/
test-docker.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
#!/bin/bash
IMAGE_FULL_NAME=${IMAGE_REPO}:${IMAGE_VERSION}
test-help-command() {
:<<DOC
Test "help" command of a tool
DOC
echo -e "\n\n Test docker image help command"
(docker run --rm ${IMAGE_FULL_NAME} | grep help) \
|| (echo 'Cannot verify help command' && exit 100)
(docker run --rm ${IMAGE_FULL_NAME} -h | grep help) \
|| (echo 'Cannot verify help command' && exit 100)
(docker run --rm ${IMAGE_FULL_NAME} --help | grep help) \
|| (echo 'Cannot verify help command' && exit 100)
}
test-checker-command() {
:<<DOC
Test "checker" command of a tool
DOC
echo -e "\n\n Test docker image checker command"
(docker run --rm ${IMAGE_FULL_NAME} | grep checker) \
|| (echo 'Cannot verify checker command' && exit 100)
}
test-image-version() {
:<<DOC
Test "version" of a docker image
DOC
echo -e "\n\n Test docker image version"
(docker run --rm ${IMAGE_FULL_NAME} | grep ${IMAGE_VERSION}) \
|| (echo 'Docker image version is wrong' && exit 100)
}
cleanup() {
:<<DOC
Cleans up environment
DOC
docker rmi ${IMAGE_FULL_NAME}
}
main() {
:<<DOC
Runs unit tests
DOC
echo -e "\n\n Docker image assessment"
test-help-command && \
test-checker-command && \
test-image-version && \
cleanup
echo -e "\n\n Docker image is ready to go"
}
main