diff --git a/Makefile b/Makefile index a9e18581..ef298ae3 100644 --- a/Makefile +++ b/Makefile @@ -406,6 +406,10 @@ test-bats-sync: check-linux binary binary-minimal bench check-skopeo $(BATS) $(N $(BATS) --trace --print-output-on-failure test/blackbox/sync_docker.bats $(BATS) --trace --print-output-on-failure test/blackbox/sync_replica_cluster.bats +.PHONY: test-bats-delete-image +test-bats-delete-image: check-linux binary binary-minimal bench check-skopeo $(BATS) + $(BATS) --trace --print-output-on-failure test/blackbox/delete_images.bats + .PHONY: test-bats-sync-verbose test-bats-sync-verbose: BUILD_LABELS=sync test-bats-sync-verbose: check-linux binary binary-minimal bench check-skopeo $(BATS) $(NOTATION) $(COSIGN) $(HELM) diff --git a/test/blackbox/delete_images.bats b/test/blackbox/delete_images.bats new file mode 100644 index 00000000..8f0a96a4 --- /dev/null +++ b/test/blackbox/delete_images.bats @@ -0,0 +1,104 @@ +load helpers_zot + +function verify_prerequisites { + if [ ! command -v curl ] &>/dev/null; then + echo "you need to install curl as a prerequisite to running the tests" >&3 + return 1 + fi + + if [ ! command -v jq ] &>/dev/null; then + echo "you need to install jq as a prerequisite to running the tests" >&3 + return 1 + fi +} + +function setup_file() { + # Verify prerequisites are available + if ! (verify_prerequisites); then + exit 1 + fi + + # Download test data to folder common for the entire suite, not just this file + skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/test-images/alpine:3.17.3 oci:${TEST_DATA_DIR}/alpine:3.17.3 + + # Setup zot server + ZOT_ROOT_DIR=${BATS_RUN_TMPDIR}/zot + echo ${ZOT_ROOT_DIR} + local zot_log_file=${BATS_RUN_TMPDIR}/zot-log.json + local zot_config_file=${BATS_RUN_TMPDIR}/zot_config.json + mkdir -p ${ZOT_ROOT_DIR} + touch ${zot_log_file} + cat >${zot_config_file} <