From f6e8fe03657821466892e9730a5bfdd1739a43fc Mon Sep 17 00:00:00 2001 From: SACHIN NAIK Date: Thu, 29 Oct 2026 11:48:57 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(test):=20bypass=20the=20proc?= =?UTF-8?q?ess-global=20PR-detail=20cache=20in=20the=20repo-item=20decisio?= =?UTF-8?q?n=20mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestRepoItemDecisionMergeDecisionsGuard failed intermittently: the own-PR guard in handlePullRequestMergeDecision reads the PR author through GetPRAuthor, which consults the process-global PR-detail cache keyed by repo+number. A "testorg/testrepo" PR #8 cached by an earlier test in the same binary (hive[bot] author, 30 min TTL) answered instead of this test's mock, so the "someone" caller was no longer the author and merge-now went through to GitHub (code=200, one PUT /merge). newRepoItemDecisionServer now sets a zero PR-detail TTL on its client so every read goes to the mock. Test-only; no production change. Hive-Run: hivecommons/hive#15461 Hive-Plan: fix flaky test (isolate PR-detail cache in test mock) Hive-Spec: ci-flake#TestRepoItemDecisionMergeDecisionsGuard Signed-off-by: SACHIN NAIK --- src/pkg/dashboard/api_repo_item_decision_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pkg/dashboard/api_repo_item_decision_test.go b/src/pkg/dashboard/api_repo_item_decision_test.go index 7309a518c5..d7f938cf3b 100644 --- a/src/pkg/dashboard/api_repo_item_decision_test.go +++ b/src/pkg/dashboard/api_repo_item_decision_test.go @@ -217,6 +217,11 @@ func newRepoItemDecisionServer(t *testing.T, m *repoItemDecisionMock) *Server { srv.deps.Config.HiveID = "h1" srv.deps.GHClient = github.NewClient("token", "testorg", []string{"testrepo"}, slog.Default(), ghSrv.URL) srv.deps.GHClient.SetAppBotLogin("hive[bot]") + // The PR-detail cache is process-global and keyed by repo+number, so a PR + // #8 cached by another test (with a different author or labels) would + // answer GetPRAuthor/GetPRState here instead of this mock. A zero TTL + // turns cache reads off for this client (hivecommons/hive#15461). + srv.deps.GHClient.SetPRDetailTTLFunc(func() time.Duration { return 0 }) store := review.NewHumanChangeRequests("") prev := repoItemDecisionChangeRequests repoItemDecisionChangeRequests = func() review.HumanChangeRequestStore { return store }