mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user