diff options
Diffstat (limited to '.extras/test-logic.sh')
| -rw-r--r-- | .extras/test-logic.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/.extras/test-logic.sh b/.extras/test-logic.sh index e48586e..d4249bb 100644 --- a/.extras/test-logic.sh +++ b/.extras/test-logic.sh @@ -107,6 +107,32 @@ load_overrides [[ ${#OV_DROP[@]} -eq 0 ]] && ok "overrides inert on 15.0" || bad "overrides applied on 15.0" VERSION_ID="current" +# --- cache ------------------------------------------------------------------ +PKG_CACHE=$(mktemp -d) +CACHE_ROOT="$PKG_CACHE/sha256-deadbeef" # simulate a resolved digest namespace +mkc() { mkdir -p "$CACHE_ROOT/$1/$2"; : > "$CACHE_ROOT/$1/$2/$3"; } + +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 got [$(cache_decision net libfoo 1.1)]" +[[ "$(cache_decision net libfoo 1.2)" == "bump:1.1:1.2" ]] && ok "cache bump reported" || bad "cache bump got [$(cache_decision net libfoo 1.2)]" +[[ "$(cache_decision net libbar 1.0)" == "new" ]] && ok "cache new for absent" || bad "cache new got [$(cache_decision net libbar 1.0)]" + +hit="$(cache_path net libfoo 1.1)" +[[ "$hit" == "$CACHE_ROOT/net/libfoo/libfoo-1.1-x86_64-1_danix.txz" ]] && ok "cache_path returns hit" || bad "cache_path got [$hit]" +[[ -z "$(cache_path net libfoo 9.9)" ]] && ok "cache_path empty on miss" || bad "cache_path not empty on miss" + +srctmp=$(mktemp -d); : > "$srctmp/libfoo-1.2-x86_64-1_danix.txz" +cache_store net libfoo "$srctmp/libfoo-1.2-x86_64-1_danix.txz" +count=$(find "$CACHE_ROOT/net/libfoo" -name '*.t?z' | wc -l) +[[ "$count" -eq 1 ]] && ok "cache_store evicts to one file" || bad "cache_store left $count files" +[[ -e "$CACHE_ROOT/net/libfoo/libfoo-1.2-x86_64-1_danix.txz" ]] && ok "cache_store stored new file" || bad "cache_store did not store" +rm -rf "$srctmp" + +# disabled cache -> new +CACHE_ROOT_SAVE="$CACHE_ROOT"; USE_CACHE=0 +[[ "$(cache_decision net libfoo 1.2)" == "new" ]] && ok "--no-cache disables (new)" || bad "disabled cache got [$(cache_decision net libfoo 1.2)]" +USE_CACHE=1; CACHE_ROOT="$CACHE_ROOT_SAVE" + echo echo "$pass passed, $fail failed" [[ $fail -eq 0 ]] || exit 1 |
