forked from gct-faisal/bitnami-docker-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
73 lines (60 loc) · 1.61 KB
/
test.sh
File metadata and controls
73 lines (60 loc) · 1.61 KB
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
#!/usr/bin/env bats
CONTAINER_NAME=bitnami-node-test
IMAGE_NAME=bitnami/node
cleanup_running_containers() {
if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then
docker rm -fv $CONTAINER_NAME
fi
}
add_app() {
docker exec $CONTAINER_NAME sh -c "echo \"
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('The night is dark and full of terrors');
});
var server = app.listen(3000, '0.0.0.0', function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
\" > /app/server.js"
}
create_container() {
docker run -id --name $CONTAINER_NAME $IMAGE_NAME
}
setup () {
cleanup_running_containers
create_container
}
teardown() {
cleanup_running_containers
}
@test "node and npm installed" {
run docker exec $CONTAINER_NAME npm -v
[ "$status" = 0 ]
run docker exec $CONTAINER_NAME node -v
[ "$status" = 0 ]
}
@test "python installed" {
run docker exec $CONTAINER_NAME python -v
[ "$status" = 0 ]
}
@test "can install npm modules with system requirements" {
run docker exec $CONTAINER_NAME\
npm install imagemagick-native bower
[ "$status" = 0 ]
}
@test "all the volumes exposed" {
docker inspect $CONTAINER_NAME | {
run grep "\"Volumes\":" -A 1
[[ "$output" =~ "/app" ]]
}
}
@test "port 3000 exposed" {
add_app
docker exec -d $CONTAINER_NAME sh -c 'npm install express && node server.js'
sleep 20
run docker run --rm --link $CONTAINER_NAME:node bitnami/node curl http://node:3000/
[[ "$output" =~ "The night is dark and full of terrors" ]]
}