From 9725b8de69c255a3eb5b99681a1bcbbb7ec144d5 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 12 Mar 2021 16:14:00 -0800 Subject: [PATCH] test: add secrets for testing Signed-off-by: Andrea Luzzardi --- .gitattributes | 3 +++ tests/test-lib.sh | 8 ++++++++ tests/test.secret | Bin 0 -> 163 bytes tests/test.sh | 42 ++++++++++++++++++++++++++++-------------- 4 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 .gitattributes create mode 100644 tests/test.secret diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..00b39fdf --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +*.secret filter=git-crypt diff=git-crypt +*.key filter=git-crypt diff=git-crypt +*.secret.* filter=git-crypt diff=git-crypt diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 34f5780e..242ee92f 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -130,3 +130,11 @@ test::one(){ disable(){ logger::warning "Test \"$2\" has been disabled." } + +secret(){ + if [ -z "${DAGGER_SECRETS_LOADED+x}" ] || [ "$DAGGER_SECRETS_LOADED" != "1" ]; then + logger::warning "Skip \"$2\": secrets not available" + else + "$@" + fi +} diff --git a/tests/test.secret b/tests/test.secret new file mode 100644 index 0000000000000000000000000000000000000000..82cd5d6c9a7127c5e086dbca95e4785e6d496380 GIT binary patch literal 163 zcmV;U09^k7M@dveQdv+`04r)@kO(t==*nOiRD)IVOS?@U__WGO$Vz${+1c9>>+Qv0 zagOiq))m^2Y%iw;D^#kY_e2oQ<+KY_Fk=lW5NzIlkpTZwsXZX1D5_ZCtPPpA))ifu zpiF?2G7SL%vcWD)k?tVdBRAD_%pp933oG*%)d8Prq#M0AoBY+idvfrNRi-HJd&u3| R_}OY~0W?5vu06{Kt?0)HO(y^V literal 0 HcmV?d00001 diff --git a/tests/test.sh b/tests/test.sh index f9843843..e38e2425 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -6,6 +6,11 @@ readonly d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd) # shellcheck source=/dev/null . "$d/test-lib.sh" +# shellcheck source=/dev/null +if grep -q "DAGGER_SECRETS" "$d/test.secret"; then + source "$d/test.secret" +fi + # Point this to your dagger binary readonly DAGGER_BINARY="${DAGGER_BINARY:-$d/../cmd/dagger/dagger}" # The default arguments are a no-op, but having "anything" is a little cheat necessary for "${DAGGER_BINARY_ARGS[@]}" to not be empty down there @@ -86,6 +91,14 @@ test::fetchcontainer(){ "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/fetch-container/nonexistent/image-with-valid-digest } +test::pushcontainer(){ + local dagger="$1" + + # Fetch container + secret test::one "FetchContainer: valid containers" --exit=0 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/fetch-container/exist +} + test::fetchgit(){ local dagger="$1" @@ -244,22 +257,23 @@ test::dockerbuild() { test::all(){ local dagger="$1" - test::load "$dagger" - test::mount "$dagger" +# test::load "$dagger" +# test::mount "$dagger" - test::copy "$dagger" - test::local "$dagger" - test::compute "$dagger" - test::fetchcontainer "$dagger" - test::fetchgit "$dagger" - test::exec "$dagger" - test::export "$dagger" - test::input "$dagger" - test::subdir "$dagger" - test::dockerbuild "$dagger" +# test::copy "$dagger" +# test::local "$dagger" +# test::compute "$dagger" +# test::fetchcontainer "$dagger" + test::pushcontainer "$dagger" +# test::fetchgit "$dagger" +# test::exec "$dagger" +# test::export "$dagger" +# test::input "$dagger" +# test::subdir "$dagger" +# test::dockerbuild "$dagger" - test::stdlib "$dagger" - test::examples "$dagger" +# test::stdlib "$dagger" +# test::examples "$dagger" } case "${1:-all}" in