Skip to content

Commit

Permalink
envutil: avoid importing testing in non-test code
Browse files Browse the repository at this point in the history
Thanks to @dt for noticing.

Release note: None
  • Loading branch information
knz committed Dec 16, 2021
1 parent d1c137d commit 84f351f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/util/envutil/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"sort"
"strconv"
"strings"
"testing"
"time"

"github.com/cockroachdb/cockroach/pkg/util/humanizeutil"
Expand Down Expand Up @@ -363,9 +362,18 @@ func EnvOrDefaultDuration(name string, value time.Duration) time.Duration {
return value
}

// TB is a slimmed down version of testing.T for use below.
// We would like to use testutils.TB but this is not possible
// due to a dependency cycle.
type TB interface {
Fatal(args ...interface{})
Helper()
}

// TestSetEnv sets an environment variable and the cleanup function
// resets it to the original value.
func TestSetEnv(t *testing.T, name string, value string) func() {
func TestSetEnv(t TB, name string, value string) func() {
t.Helper()
ClearEnvCache()
before, exists := os.LookupEnv(name)

Expand Down

0 comments on commit 84f351f

Please sign in to comment.