From 1580824aa26b6ff66146ff6aac78158fd0eebf7f Mon Sep 17 00:00:00 2001 From: Abe Winter Date: Wed, 4 Sep 2024 19:22:32 -0400 Subject: [PATCH] deprecate utils.Testing in favor of testing.Testing --- utils/value.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/value.go b/utils/value.go index be5a5343391..d8adc54f54c 100644 --- a/utils/value.go +++ b/utils/value.go @@ -1,10 +1,10 @@ package utils import ( - "flag" "math/rand" "os" "strings" + "testing" ) // AssertType attempts to assert that the given interface argument is @@ -46,9 +46,9 @@ type Rand interface { } // Testing returns true when you are running in test suite. +// Deprecated: this is in the standard library now. func Testing() bool { - // TODO switch to official testing.Testing method when we are on go 1.21 - return flag.Lookup("test.v") != nil + return testing.Testing() } // randWrapper is a pass-through to the shared math/rand functions. @@ -61,7 +61,7 @@ func (randWrapper) Float64() float64 { // SafeTestingRand returns a wrapper around the shared math/rand source in prod, // and a deterministic rand.Rand seeded with 0 in test. func SafeTestingRand() Rand { - if Testing() { + if testing.Testing() { return rand.New(rand.NewSource(0)) //nolint:gosec } return randWrapper{}