diff --git a/Dockerfile b/Dockerfile index 57f018f..2ebb588 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,9 +59,12 @@ ENV PATH=/data/node_modules/.bin:$PATH # Temporary build stage where we can run the test suite. FROM base AS test -COPY --from=ghcr.io/goss-org/goss:latest /usr/bin/goss /usr/bin/goss -ADD goss.yml /tmp/goss.yml -RUN goss --gossfile=/tmp/goss.yml validate + +USER root +RUN apk add bats + +ADD tests.bats /tmp/tests.bats +RUN bats /tmp/tests.bats FROM base AS run CMD ["bash"] diff --git a/goss.yml b/goss.yml deleted file mode 100644 index 23ae89f..0000000 --- a/goss.yml +++ /dev/null @@ -1,18 +0,0 @@ -command: - npm: - exec: "npm --help" - exit-status: 1 - stdout: - - DISCLAIMER - - yarn: - exec: "yarn --help" - exit-status: 0 - stdout: - - DISCLAIMER - - pnpm: - exec: "pnpm --help" - exit-status: 0 - stdout: - - "compiled to binary" diff --git a/tests.bats b/tests.bats new file mode 100644 index 0000000..40afde8 --- /dev/null +++ b/tests.bats @@ -0,0 +1,25 @@ +#!/usr/bin/env bats + +setup() { + # load helper libraries when using the official Docker image + bats_load_library bats-support + bats_load_library bats-assert +} + +@test "npm --help exits 1 and mentions DISCLAIMER" { + run npm --help + [ "$status" -eq 1 ] + assert_output --partial "DISCLAIMER" +} + +@test "yarn --help exits 0 and mentions DISCLAIMER" { + run yarn --help + [ "$status" -eq 0 ] + assert_output --partial "DISCLAIMER" +} + +@test "pnpm --help exits 0 and mentions 'compiled to binary'" { + run pnpm --help + [ "$status" -eq 0 ] + assert_output --partial "compiled to binary" +}