summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-27 09:47:31 +0200
committerDanilo M. <danix@danix.xyz>2026-06-27 09:47:31 +0200
commit90f5ad0486158191d0fc03d347fa522d90f1f815 (patch)
treee7ff3b3c86fc328d3a8c14d1ecdd023c6e472bb5
parent11e9c4c9b5d4bb00cbb9fc8d7132dfc52b7ab19c (diff)
downloadmkhintfile-90f5ad0486158191d0fc03d347fa522d90f1f815.tar.gz
mkhintfile-90f5ad0486158191d0fc03d347fa522d90f1f815.zip
test: cover -R <pkg...> named-hint review (T44-T47)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-rwxr-xr-xtests/mkhint_test.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh
index 4ee3059..102790d 100755
--- a/tests/mkhint_test.sh
+++ b/tests/mkhint_test.sh
@@ -871,6 +871,72 @@ EOF
run_mkhint -C curl clion < <(printf '\n') > /dev/null 2>&1
assert_not_contains "two-pkg check has no -e" "$MOCK_BASE/nvchecker.log" '\-e '
+# ── T44: -R <pkg> reviews a non-matched hint, Keep leaves it ──────────────────
+echo ""
+echo "T44: -R <pkg> on a non-matched hint → diff shown, Keep leaves it"
+rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null
+# clion hint version differs from its .info → not matched by bare -R
+cat > "$MOCK_HINT/clion.hint" << 'EOF'
+VERSION="9.9.9"
+ARCH="x86_64"
+DOWNLOAD="UNSUPPORTED"
+MD5SUM=""
+EOF
+out=$(run_mkhint -R clion < <(printf 'K\n') 2>&1)
+assert_file_exists "named non-matched hint kept" "$MOCK_HINT/clion.hint"
+echo "$out" | grep -q "=== clion ===" \
+ && { echo " PASS: diff header shown for named hint"; (( PASS++ )); } \
+ || { echo " FAIL: diff header missing"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T44 header"); }
+
+# ── T45: -R <pkg> answer D → named hint and .bak removed ──────────────────────
+echo ""
+echo "T45: -R <pkg> answer D → named hint and .bak removed"
+rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null
+cat > "$MOCK_HINT/clion.hint" << 'EOF'
+VERSION="9.9.9"
+ARCH="x86_64"
+DOWNLOAD="UNSUPPORTED"
+MD5SUM=""
+EOF
+touch "$MOCK_HINT/clion.hint.bak"
+out=$(run_mkhint -R clion < <(printf 'D\n') 2>&1)
+assert_file_not_exists "named hint deleted" "$MOCK_HINT/clion.hint"
+assert_file_not_exists "named bak deleted" "$MOCK_HINT/clion.hint.bak"
+echo "$out" | grep -q "deleted 1" \
+ && { echo " PASS: summary reports deleted 1"; (( PASS++ )); } \
+ || { echo " FAIL: summary wrong"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T45 summary"); }
+
+# ── T46: -R <pkg1> <pkg2> → both reviewed ────────────────────────────────────
+echo ""
+echo "T46: -R two packages → both reviewed, summary counts 2"
+rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null
+cat > "$MOCK_HINT/clion.hint" << 'EOF'
+VERSION="9.9.9"
+ARCH="x86_64"
+DOWNLOAD="UNSUPPORTED"
+MD5SUM=""
+EOF
+cat > "$MOCK_HINT/curl.hint" << 'EOF'
+VERSION="9.9.9"
+ARCH="x86_64"
+DOWNLOAD="UNSUPPORTED"
+MD5SUM=""
+EOF
+out=$(run_mkhint -R clion curl < <(printf 'K\nK\n') 2>&1)
+echo "$out" | grep -q "Reviewed 2 hint" \
+ && { echo " PASS: summary reports 2 reviewed"; (( PASS++ )); } \
+ || { echo " FAIL: summary count wrong"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T46 count"); }
+
+# ── T47: -R <missing> → exit 2 ───────────────────────────────────────────────
+echo ""
+echo "T47: -R missing package → exit 2"
+rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null
+set +e
+out=$(run_mkhint -R nope < <(printf 'K\n') 2>&1)
+code=$?
+set -e
+assert_exit_code "missing named hint exits 2" 2 "$code"
+
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
teardown