diff --git a/test-build.sh b/test-build.sh index 61861e9e..e4a137a0 100755 --- a/test-build.sh +++ b/test-build.sh @@ -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 diff --git a/test-image.bats b/test-image.bats new file mode 100755 index 00000000..0ed16486 --- /dev/null +++ b/test-image.bats @@ -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 ] +} diff --git a/test-image.sh b/test-image.sh deleted file mode 100755 index e409e3bc..00000000 --- a/test-image.sh +++ /dev/null @@ -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."