test: add secrets for testing

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-03-12 16:14:00 -08:00
parent 9d916a2fc2
commit 9725b8de69
4 changed files with 39 additions and 14 deletions

3
.gitattributes vendored Normal file
View File

@ -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

View File

@ -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
}

BIN
tests/test.secret Normal file

Binary file not shown.

View File

@ -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