aboutsummaryrefslogtreecommitdiffstats
path: root/test-logic.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-25 10:05:08 +0200
committerDanilo M. <danix@danix.xyz>2026-09-25 10:05:08 +0200
commitded593dc529916f1bf23f2df38f975db1c1e69e8 (patch)
tree7f3c60069cddd61789c068d30578cb69755dfeec /test-logic.sh
parent2fd4fa399e980e3ea351df435d0f0eb2841679d8 (diff)
downloadsbo-dockerbuild-ded593dc529916f1bf23f2df38f975db1c1e69e8.tar.gz
sbo-dockerbuild-ded593dc529916f1bf23f2df38f975db1c1e69e8.zip
test-build: add --pull to refresh a stale local image
require_image pulled only when the image was missing, so once the image-builder rebuilt a registry tag the local copy went stale with no warning. --pull runs `docker pull` first, which compares digests itself and costs one manifest request when nothing changed. If the registry is unreachable it falls back to the local copy with a warning, and still fails when there is none. The README documents a daily cron pull for machines that run test-build, and the skill notes that local images are not refreshed automatically. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test-logic.sh')
-rw-r--r--test-logic.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/test-logic.sh b/test-logic.sh
index 563eb30..a46b582 100644
--- a/test-logic.sh
+++ b/test-logic.sh
@@ -234,6 +234,36 @@ if depends_on_failed "$T/cat/a" dead; then bad "a blocked with empty dead"; else
dead=("%README%")
if depends_on_failed "$T/cat/a" dead; then bad "%README% treated as dep"; else ok "%README% not treated as dep"; fi
+# --- require_image / --pull ---------------------------------------------------
+# Stub docker: records "pull"/"inspect" calls; STUB_PULL / STUB_LOCAL set outcomes.
+echo "require_image:"
+docker() {
+ CALLS+="$1 "
+ case "$1" in
+ pull) [[ $STUB_PULL -eq 0 ]] ;;
+ image) [[ $STUB_LOCAL -eq 1 ]] ;;
+ esac
+}
+ACTIVE_IMAGE="reg/img:current"
+PULL_IMAGE=0; parse_args --pull pkg >/dev/null 2>&1
+[[ $PULL_IMAGE -eq 1 ]] && ok "--pull sets PULL_IMAGE" || bad "--pull not parsed"
+TARGET_ARG=""
+
+PULL_IMAGE=0; STUB_LOCAL=1; STUB_PULL=0; CALLS=""
+require_image 2>/dev/null
+[[ $CALLS == "image " ]] && ok "no --pull + local: no pull" || bad "no --pull + local: calls '$CALLS'"
+
+PULL_IMAGE=1; STUB_LOCAL=1; STUB_PULL=0; CALLS=""
+require_image 2>/dev/null
+[[ $CALLS == "pull " ]] && ok "--pull: pulls even when local" || bad "--pull: calls '$CALLS'"
+
+PULL_IMAGE=1; STUB_LOCAL=1; STUB_PULL=1; CALLS=""
+( require_image ) 2>/dev/null && ok "--pull fails + local: falls back" || bad "--pull fails + local: exited"
+
+PULL_IMAGE=1; STUB_LOCAL=0; STUB_PULL=1; CALLS=""
+( require_image ) 2>/dev/null && bad "--pull fails + no local: should exit" || ok "--pull fails + no local: exits"
+unset -f docker; PULL_IMAGE=0
+
echo
echo "$pass passed, $fail failed"
[[ $fail -eq 0 ]] || exit 1