Skip to content

Commit

Permalink
internal/telemetry: remove "testing" import from `internal/telemetry/…
Browse files Browse the repository at this point in the history
…utils.go` (#3017)
  • Loading branch information
paulcacheux authored Dec 9, 2024
1 parent 17415ba commit 79a1f60
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/telemetry/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"math"
"sort"
"strings"
"testing"
)

// MockGlobalClient replaces the global telemetry client with a custom
Expand All @@ -30,8 +29,16 @@ func MockGlobalClient(client Client) func() {
}
}

// Errorfer is an interface that allows to call the `Errorf` method.
// This is the same interface as `testing.T` because the goal of this
// interface is to remove the need to import `testing` in this package
// that is actually imported by users.
type Errorfer interface {
Errorf(format string, args ...any)
}

// Check is a testing utility to assert that a target key in config contains the expected value
func Check(t *testing.T, configuration []Configuration, key string, expected interface{}) {
func Check(t Errorfer, configuration []Configuration, key string, expected interface{}) {
for _, kv := range configuration {
if kv.Name == key {
if kv.Value != expected {
Expand Down

0 comments on commit 79a1f60

Please sign in to comment.