fix(coderd/database/dbauthz): skip Accounting check when sub-test filtering (#23281)

- 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. 🧑‍💻
This commit is contained in:
Cian Johnston
2026-03-24 14:58:04 +00:00
committed by GitHub
parent be5e080de6
commit fd1e2f0dd9
+11
View File
@@ -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 {