chore: replace testing.Testing with flag lookup (#26552)

In our codebase we have an existing convention of using
`flag.Lookup("test.v")` instead of `testing.Testing()`. This avoids
pulling in the entire `testing` package. Another consequence: some of
our custom linters trigger upon import of the `testing` package which
can lead to unexpected linter errors.
This commit is contained in:
Cian Johnston
2026-06-19 19:59:54 +01:00
committed by GitHub
parent befa1176b9
commit d5ec26beac
5 changed files with 10 additions and 11 deletions
+2 -2
View File
@@ -5,10 +5,10 @@ import (
"database/sql"
"encoding/json"
"errors"
"flag"
"slices"
"strings"
"sync/atomic"
"testing"
"time"
"github.com/google/uuid"
@@ -2611,7 +2611,7 @@ func (q *querier) DeleteWorkspaceSubAgentByID(ctx context.Context, id uuid.UUID)
}
func (q *querier) DisableForeignKeysAndTriggers(ctx context.Context) error {
if !testing.Testing() {
if flag.Lookup("test.v") == nil {
return xerrors.Errorf("DisableForeignKeysAndTriggers is only allowed in tests")
}
return q.db.DisableForeignKeysAndTriggers(ctx)