diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-13 17:37:10 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-13 17:37:10 +0200 |
| commit | 29bbd6377f6e2758b1dea6bcba2f89c991484a19 (patch) | |
| tree | 4195e4621d3a20ff9d6fa4471f7a1e9e61a66dba /tests | |
| parent | 545d6f70bfd01d7397d661d3c3b1ae73efa3c431 (diff) | |
| download | mkhintfile-29bbd6377f6e2758b1dea6bcba2f89c991484a19.tar.gz mkhintfile-29bbd6377f6e2758b1dea6bcba2f89c991484a19.zip | |
test: add T27 (downgrade flag) and T28 (--check scan-all)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/mkhint_test.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index 591c163..4f3b74f 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -544,6 +544,47 @@ code=$? set -e assert_exit_code "check + -v exits 1" 1 "$code" +# ── T27: --check upstream older than hint → (?downgrade) flag ────────────────── +echo "" +echo "T27: --check when upstream version is older → reported as (?downgrade)" +cat > "$MOCK_BASE/new_ver.json" << 'EOF' +{ "version": 2, "data": { "curl": { "version": "8.0.0" } } } +EOF +cat > "$MOCK_HINT/curl.hint" << 'EOF' +VERSION="8.9.0" +ARCH="x86_64" +DOWNLOAD="https://curl.se/download/curl-8.9.0.tar.gz" +MD5SUM="abc123def456abc123def456abc123de" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +EOF +# decline the update (n), so hint stays unchanged; capture report output +out=$(run_mkhint -C curl < <(printf 'n\n') 2>&1) +echo "$out" | grep -q "(?downgrade)" \ + && { echo " PASS: downgrade flagged in report"; (( PASS++ )); } \ + || { echo " FAIL: (?downgrade) not in report"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T27 downgrade flag"); } +assert_contains "curl unchanged after decline" "$MOCK_HINT/curl.hint" 'VERSION="8.9.0"' + +# ── T28: --check with no args → scans all hints in HINT_DIR ──────────────────── +echo "" +echo "T28: --check with no package args scans entire HINT_DIR" +# only curl present and outdated; new_ver has curl 8.9.0 +cat > "$MOCK_BASE/new_ver.json" << 'EOF' +{ "version": 2, "data": { "curl": { "version": "8.9.0" } } } +EOF +rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null +cat > "$MOCK_HINT/curl.hint" << 'EOF' +VERSION="8.5.0" +ARCH="x86_64" +DOWNLOAD="https://curl.se/download/curl-8.5.0.tar.gz" +MD5SUM="abc123def456abc123def456abc123de" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +EOF +# no pkg args → scan-all; accept curl (Y), decline slackrepo (n) +run_mkhint -C < <(printf 'Y\nn\n') +assert_contains "scan-all updated curl" "$MOCK_HINT/curl.hint" 'VERSION="8.9.0"' + # ─── SUMMARY ────────────────────────────────────────────────────────────────── teardown |
