feat: v2.0 iteration — test coverage, reliability, observability
M0: Test coverage expansion (151 → 321 tests, 61% → 66% lines) - normalizeKnowledge CRLF/LF normalization fix - gooseReviewer: 11 tests, 97.35% coverage - r2 storage: 22 tests, 100% coverage - triage processor: 11 tests, exported buildTriagePrompt/labelName - webhook processor: 35 tests, 72.39% coverage - conflict resolver: 12 tests - review processor: 7 tests M1: Reliability hardening - Smart retry with jitter, maxTotalTimeoutMs, custom retryable predicate - MergeGuard: in-memory merge dedup tracker (100% coverage) - failureMessages: 7-category failure classifier (100% coverage) M2: Observability - MetricsCollector: Actions-run metrics with snapshot/markdown/reset - 11 tests, 100% coverage New files: 12 test files, 3 source modules All gates: typecheck ✓ lint ✓ format ✓ 321/321 tests ✓ build ✓
This commit is contained in:
1 parent
db53296d78
commit
78bf8e9e41
87 files changed
+6003
-2587
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { MergeGuard } from "../src/review/merge-guard.js";
|
||||
|
||||
test("markAttempt followed by isAlreadyAttempted returns true", () => {
|
||||
const guard = new MergeGuard();
|
||||
guard.markAttempt("owner1", "repo1", 42);
|
||||
assert.equal(guard.isAlreadyAttempted("owner1", "repo1", 42), true);
|
||||
});
|
||||
|
||||
test("isAlreadyAttempted returns false for a never-attempted PR", () => {
|
||||
const guard = new MergeGuard();
|
||||
assert.equal(guard.isAlreadyAttempted("owner1", "repo1", 99), false);
|
||||
});
|
||||
|
||||
test("getRecentAttempts returns list of attempted PR keys", () => {
|
||||
const guard = new MergeGuard();
|
||||
guard.markAttempt("a", "repo-a", 1);
|
||||
guard.markAttempt("b", "repo-b", 2);
|
||||
const attempts = guard.getRecentAttempts();
|
||||
assert.equal(attempts.length, 2);
|
||||
assert.ok(attempts.includes("a/repo-a#1"));
|
||||
assert.ok(attempts.includes("b/repo-b#2"));
|
||||
});
|
||||
|
||||
test("multiple attempts on the same PR increment count", () => {
|
||||
const guard = new MergeGuard();
|
||||
guard.markAttempt("same", "pr", 1);
|
||||
guard.markAttempt("same", "pr", 1);
|
||||
guard.markAttempt("same", "pr", 1);
|
||||
assert.equal(guard.getAttemptedCount(), 3);
|
||||
assert.equal(guard.isAlreadyAttempted("same", "pr", 1), true);
|
||||
});
|
||||
|
||||
test("different PRs are tracked independently", () => {
|
||||
const guard = new MergeGuard();
|
||||
guard.markAttempt("owner1", "repo1", 10);
|
||||
guard.markAttempt("owner2", "repo2", 20);
|
||||
|
||||
assert.equal(guard.isAlreadyAttempted("owner1", "repo1", 10), true);
|
||||
assert.equal(guard.isAlreadyAttempted("owner1", "repo1", 11), false);
|
||||
assert.equal(guard.isAlreadyAttempted("owner2", "repo2", 20), true);
|
||||
assert.equal(guard.isAlreadyAttempted("owner2", "repo2", 21), false);
|
||||
|
||||
assert.equal(guard.getAttemptedCount(), 2);
|
||||
});
|
||||
Reference in new issue
Block a user