Use BATS for testing

Switches testing to the BATS testing framework:
https://github.com/bats-core/bats-core
This commit is contained in:
Christopher Horrell 2018-06-02 11:03:45 -04:00
parent b22fb6c84e
commit 3bfd15f786
No known key found for this signature in database
GPG Key ID: 6E82CA4127747B7C
3 changed files with 20 additions and 19 deletions

View File

@ -46,7 +46,9 @@ function build() {
info "Build of ${full_tag} succeeded."
info "Testing ${full_tag}"
docker run --rm -v "$PWD/test-image.sh:/usr/local/bin/test.sh" node:"${full_tag}" test.sh "${full_version}"
export full_tag=${full_tag}
export full_version=${full_version}
bats test-image.bats
}
cd "$(cd "${0%/*}" && pwd -P)" || exit

17
test-image.bats Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bats
@test "Test for node and version" {
run docker run --rm -it node:"$full_tag" node -e "process.stdout.write(process.versions.node)"
[ "$status" -eq 0 ]
[ "$output" == "${full_version}" ]
}
@test "Test for npm" {
run docker run --rm -it node:"$full_tag" npm --version
[ "$status" -eq 0 ]
}
@test "Test for yarn" {
run docker run --rm -it node:"$full_tag" yarn --version
[ "$status" -eq 0 ]
}

View File

@ -1,18 +0,0 @@
#!/bin/sh
if [ "$(node -e "process.stdout.write(process.versions.node)")" != "${1}" ]; then
echo "Test for node failed!"
exit 1
fi
echo "Test for node succeeded."
if ! npm --version >/dev/null; then
echo "Test for npm failed!"
exit 1
fi
echo "Test for npm succeeded."
if ! yarn --version >/dev/null; then
echo "Test of yarn failed!"
exit 1
fi
echo "Test for yarn succeeded."