From e8d8afb3007567616b20d07c7467e04388c714a0 Mon Sep 17 00:00:00 2001 From: Gavin Didrichsen Date: Thu, 13 Jun 2019 20:15:13 +0100 Subject: [PATCH] Fix according to all comments, especially: * Reduce test.bats to just the version check * Fix test.sh to show the usage() on failure * Amend README to reference the test standards document Signed-off-by: Gavin Didrichsen --- acl/README.md | 4 ++++ acl/tests/test.bats | 5 +++++ acl/tests/test.sh | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 acl/tests/test.bats create mode 100755 acl/tests/test.sh diff --git a/acl/README.md b/acl/README.md index 3771360d16..745b38cf58 100644 --- a/acl/README.md +++ b/acl/README.md @@ -13,3 +13,7 @@ Binary package ## Usage *TODO: Add instructions for usage* + +# Testing + +To run tests follow the example in the latest [test standards document](https://github.com/habitat-sh/core-plans/blob/master/docs/dev/policy_documents/standards-for-tests.md). diff --git a/acl/tests/test.bats b/acl/tests/test.bats new file mode 100644 index 0000000000..d8acbf30e7 --- /dev/null +++ b/acl/tests/test.bats @@ -0,0 +1,5 @@ +@test "Version matches plan" { + TEST_PKG_VERSION="$(echo "${TEST_PKG_IDENT}" | cut -d/ -f3)" + actual_version="$(hab pkg exec "${TEST_PKG_IDENT}" getfacl --version | awk '{print $2}')" + [[ "$actual_version" = "${TEST_PKG_VERSION}" ]] +} diff --git a/acl/tests/test.sh b/acl/tests/test.sh new file mode 100755 index 0000000000..16baa2245a --- /dev/null +++ b/acl/tests/test.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -euo pipefail + +#/ Usage: test.sh +#/ +#/ Example: test.sh core/opa/0.11.0/20190531065119 +#/ + +TESTDIR="$(dirname "${0}")" + +if [[ -z "${1:-}" ]]; then + grep '^#/' < "${0}" | cut -c4- + exit 1 +fi + +TEST_PKG_IDENT="$1" + +hab pkg install core/bats --binlink +hab pkg install "$TEST_PKG_IDENT" + +export TEST_PKG_IDENT +bats "${TESTDIR}/test.bats"