-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathdocker-image.bats
36 lines (29 loc) · 1.06 KB
/
docker-image.bats
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
# Docs: https://bats-core.readthedocs.io/en/stable/writing-tests.html
setup() {
tmp_file=$(mktemp)
echo 'console.log("success")' > "${tmp_file}"
}
@test "Test for node version" {
run -0 docker run --rm "${IMAGE_TAG}" node --print "process.versions.node"
[ "$output" = "${NODE_VERSION}" ]
}
@test "Test for node version, without directly invoking node" {
run -0 docker run --rm "${IMAGE_TAG}" --print "process.versions.node"
[ "$output" = "${NODE_VERSION}" ]
}
@test "Test for npm" {
run -0 docker run --rm "${IMAGE_TAG}" npm --version
[ -n "$output" ]
}
@test "Test for yarn" {
run -0 docker run --rm "${IMAGE_TAG}" yarn --version
[ -n "$output" ]
}
@test "Verify entrypoint runs relative path pointing to regular, non-executable file with node" {
run -0 docker run --rm -v "${tmp_file}:/index.js" "${IMAGE_TAG}" index.js
[ "$output" = 'success' ]
}
@test "Verify entrypoint runs absolute path pointing to regular, non-executable file with node" {
run -0 docker run --rm -v "${tmp_file}:/index.js" "${IMAGE_TAG}" /index.js
[ "$output" = 'success' ]
}