diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-24 16:34:02 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-24 16:34:02 +0200 |
| commit | 492152f91a5d5668b384916321ae1b59c72bfb43 (patch) | |
| tree | 3c3fb748c65f23b18ac84ed98519a5ef8af61dbe /test-logic.sh | |
| parent | 5bccfedb2c4fc7f592d225b7d88a5183d27e9906 (diff) | |
| download | sbo-batch-tester-492152f91a5d5668b384916321ae1b59c72bfb43.tar.gz sbo-batch-tester-492152f91a5d5668b384916321ae1b59c72bfb43.zip | |
Add cache_decision + tests
Implements cache_decision <cat> <prog> <version> which inspects
$PKG_CACHE/<cat>/<prog>/ and returns "cached", "bump:OLD:NEW", or "new".
Empty PKG_CACHE disables the cache. Tests in test-logic.sh cover all
four outcomes and are driven pure (no VM needed).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'test-logic.sh')
| -rwxr-xr-x | test-logic.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test-logic.sh b/test-logic.sh index 13d97f8..7575ea7 100755 --- a/test-logic.sh +++ b/test-logic.sh @@ -104,6 +104,25 @@ else bad "cascade dead: b=${blocked[b]:-0} a=${blocked[a]:-0}" fi +# --- package cache ---------------------------------------------------------- +PKG_CACHE=$(mktemp -d) +mkc() { mkdir -p "$PKG_CACHE/$1/$2"; : > "$PKG_CACHE/$1/$2/$3"; } + +# exact version match -> cached +mkc net libfoo "libfoo-1.1-x86_64-1_danix.txz" +[[ "$(cache_decision net libfoo 1.1)" == "cached" ]] && ok "cache hit on version match" || bad "cache_decision should be cached, got [$(cache_decision net libfoo 1.1)]" + +# different version cached -> bump:old:new +[[ "$(cache_decision net libfoo 1.2)" == "bump:1.1:1.2" ]] && ok "cache bump reported" || bad "cache_decision bump wrong, got [$(cache_decision net libfoo 1.2)]" + +# nothing cached -> new +[[ "$(cache_decision net libbar 1.0)" == "new" ]] && ok "cache new for absent prog" || bad "cache_decision should be new, got [$(cache_decision net libbar 1.0)]" + +# empty PKG_CACHE disables -> new +PKG_CACHE_SAVE="$PKG_CACHE"; PKG_CACHE="" +[[ "$(cache_decision net libfoo 1.1)" == "new" ]] && ok "empty PKG_CACHE disables (new)" || bad "disabled cache should be new, got [$(cache_decision net libfoo 1.1)]" +PKG_CACHE="$PKG_CACHE_SAVE" + # --- result ----------------------------------------------------------------- echo echo "$pass passed, $fail failed" |
