forked from heavy-duty/ceremony
test: cover offsite nudge integration
This commit is contained in:
parent
bc3c1bd5cf
commit
5216369e7e
1 changed files with 55 additions and 0 deletions
|
|
@ -208,6 +208,8 @@ issue_stub_gh() {
|
|||
shift
|
||||
done
|
||||
file="$TMP/$(printf '%s' "$endpoint" | tr '/' '_').json"
|
||||
printf '%s\n' "$endpoint" >>"$TMP/api-calls"
|
||||
[ ! -f "$file.error" ] || return 1
|
||||
[ -f "$file" ] || { printf '[]\n'; return 0; }
|
||||
if [ -n "$jqexpr" ]; then jq -r "$jqexpr" "$file"; else cat "$file"; fi
|
||||
elif [ "$1" = issue ] && [ "$2" = comment ]; then
|
||||
|
|
@ -289,6 +291,59 @@ check "an offsite claim with an open PR stays claimed" 1 "" \
|
|||
offsite_both="$(issue_probe 28 $'claimed\noffsite\nneeds-ruling')"
|
||||
check "offsite plus needs-ruling stays claimed" 1 "" \
|
||||
grep -q 'reclaimed' <<<"$offsite_both"
|
||||
|
||||
# -- resolved offsite work nudges once and only from complete evidence -------
|
||||
jq -n --arg at "$(iso_at $((INOW - 3600)))" \
|
||||
'[{"event":"assigned","created_at":$at},
|
||||
{"event":"cross-referenced","source":{"issue":{"number":112,"repository":{"full_name":"heavy-duty/rig"},"pull_request":{"url":"x"}}}}]' \
|
||||
>"$(tfix 29)"
|
||||
printf '{"state":"closed"}\n' >"$TMP/repos_heavy-duty_rig_pulls_112.json"
|
||||
printf '[]\n' >"$(cfix 29)"
|
||||
resolved="$(issue_probe 29 $'claimed\noffsite')"
|
||||
check "a closed cross-referenced PR nudges and names the PR" 0 "" \
|
||||
grep -q 'heavy-duty/rig#112 is closed' "$TMP/posted-29"
|
||||
check "the resolved nudge leaves the claim untouched" 1 "" \
|
||||
grep -q 'reclaimed' <<<"$resolved"
|
||||
issue_probe 29 $'claimed\noffsite' >/dev/null
|
||||
check "the resolved nudge is idempotent across sweeps" 0 "1" \
|
||||
grep -cF '<!-- issueflow:offsite-resolved -->' "$TMP/posted-29"
|
||||
|
||||
jq -n --arg at "$(iso_at $((INOW - 3600)))" \
|
||||
'[{"event":"assigned","created_at":$at},
|
||||
{"event":"cross-referenced","source":{"issue":{"number":112,"repository":{"full_name":"heavy-duty/rig"},"pull_request":{"url":"x"}}}},
|
||||
{"event":"cross-referenced","source":{"issue":{"number":9,"repository":{"full_name":"heavy-duty/box"},"pull_request":{"url":"x"}}}}]' \
|
||||
>"$(tfix 30)"
|
||||
printf '{"state":"open"}\n' >"$TMP/repos_heavy-duty_box_pulls_9.json"
|
||||
printf '[]\n' >"$(cfix 30)"
|
||||
issue_probe 30 $'claimed\noffsite' >/dev/null
|
||||
check "one open cross-referenced PR suppresses the nudge" 1 "" \
|
||||
test -f "$TMP/posted-30"
|
||||
|
||||
printf '[]\n' >"$(tfix 31)"
|
||||
printf '[]\n' >"$(cfix 31)"
|
||||
issue_probe 31 $'claimed\noffsite' >/dev/null
|
||||
check "no visible cross-referenced PR stays silent" 1 "" test -f "$TMP/posted-31"
|
||||
|
||||
: >"$(tfix 32).error"
|
||||
printf '[]\n' >"$(cfix 32)"
|
||||
unreadable="$(issue_probe 32 $'claimed\noffsite')"
|
||||
check "an unreadable timeline stays silent" 1 "" test -f "$TMP/posted-32"
|
||||
check "...and leaves the sweep running without an alarming log" 1 "" \
|
||||
grep -qiE 'error|failed' <<<"$unreadable"
|
||||
|
||||
: >"$TMP/api-calls"
|
||||
printf '[]\n' >"$(tfix 33)"
|
||||
printf '[]\n' >"$(cfix 33)"
|
||||
issue_probe 33 claimed >/dev/null
|
||||
check "a non-offsite claim performs only the ordinary timeline read" 0 "1" \
|
||||
grep -cF 'repos/owner/repo/issues/33/timeline' "$TMP/api-calls"
|
||||
: >"$TMP/api-calls"
|
||||
printf '[]\n' >"$(tfix 34)"
|
||||
printf '[]\n' >"$(cfix 34)"
|
||||
issue_probe 34 $'claimed\noffsite' >/dev/null
|
||||
check "an offsite claim performs the one guarded verification read" 0 "2" \
|
||||
grep -cF 'repos/owner/repo/issues/34/timeline' "$TMP/api-calls"
|
||||
|
||||
check "a one-hour claim stays claimed for the ordinary age reason" 0 "KEEP" \
|
||||
claim_decision 1 false 3600
|
||||
check "no reconciler mutation names offsite (#68 D4)" 1 "" \
|
||||
|
|
|
|||
Loading…
Reference in a new issue