From fd1e2f0dd9a54d52589ae4dbf048c96dcb0ad379 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 24 Mar 2026 14:58:04 +0000 Subject: [PATCH] fix(coderd/database/dbauthz): skip Accounting check when sub-test filtering (#23281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Detect `-testify.m` sub-test filtering in `SetupSuite` and skip the `Accounting` check. > 🤖 This PR was created with the help of Coder Agents, and was reviewed by my human. 🧑‍💻 --- coderd/database/dbauthz/setup_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/coderd/database/dbauthz/setup_test.go b/coderd/database/dbauthz/setup_test.go index da12831970..3a100d7e1b 100644 --- a/coderd/database/dbauthz/setup_test.go +++ b/coderd/database/dbauthz/setup_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/gob" "errors" + "flag" "fmt" "reflect" "slices" @@ -90,6 +91,16 @@ func (s *MethodTestSuite) SetupSuite() { // TearDownSuite asserts that all methods were called at least once. func (s *MethodTestSuite) TearDownSuite() { s.Run("Accounting", func() { + // testify/suite's -testify.m flag filters which suite methods + // run, but TearDownSuite still executes. Skip the Accounting + // check when filtering to avoid misleading "method never + // called" errors for every method that was filtered out. + if f := flag.Lookup("testify.m"); f != nil { + if f.Value.String() != "" { + s.T().Skip("Skipping Accounting check: -testify.m flag is set") + } + } + t := s.T() notCalled := []string{} for m, c := range s.methodAccounting {