fix: bats test refactoring (#1731)

Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
Alexei Dodon
2023-08-30 22:24:28 +03:00
committed by GitHub
parent 112fbec5b6
commit 41bbb23e30
29 changed files with 521 additions and 821 deletions
+17 -15
View File
@@ -1,14 +1,21 @@
# Note: Intended to be run as "make test-bats-scrub" or "make test-bats-scrub-verbose"
# Makefile target installs & checks all necessary tooling
# Extra tools that are not covered in Makefile target needs to be added in verify_prerequisites()
load helpers_zot
load helpers_scrub
function verify_prerequisites() {
return 0
}
function setup_file(){
skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/golang:1.20 oci:${TEST_DATA_DIR}/golang:1.20
}
function setup() {
# verify prerequisites are available
if ! verify_prerequisites; then
echo "oh noooooo"
if ! $(verify_prerequisites); then
exit 1
fi
@@ -21,7 +28,7 @@ function setup() {
touch ${ZOT_LOG_FILE}
cat >${ZOT_CONFIG_FILE} <<EOF
{
"distSpecVersion": "1.1.0",
"distSpecVersion": "1.1.0-dev",
"storage": {
"rootDirectory": "${ZOT_ROOT_DIR}",
"dedupe": false
@@ -42,23 +49,20 @@ function setup() {
}
}
EOF
}
function teardown() {
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
teardown_zot_file_level
rm -rf ${zot_root_dir}
zot_stop_all
}
@test "blobs/manifest integrity not affected" {
add_test_files
echo ${ZOT_CONFIG_FILE}
setup_zot_file_level ${ZOT_CONFIG_FILE}
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
zot_serve ${ZOT_PATH} ${ZOT_CONFIG_FILE}
wait_zot_reachable 8080
# wait for scrub to be done and logs to get populated
run sleep 15s
@@ -68,18 +72,16 @@ function teardown() {
}
@test "blobs/manifest integrity affected" {
add_test_files
delete_blob
echo ${ZOT_CONFIG_FILE}
setup_zot_file_level ${ZOT_CONFIG_FILE}
wait_zot_reachable "http://127.0.0.1:8080/v2/_catalog"
zot_serve ${ZOT_PATH} ${ZOT_CONFIG_FILE}
wait_zot_reachable 8080
# wait for scrub to be done and logs to get populated
run sleep 15s
run affected
[ "$status" -eq 0 ]
[ $(echo "${lines[0]}" ) = 'true' ]
# [ $(echo "${lines[-1]}" | jq .) ]
}