test: Remove use of "mitchellh/go-testing-interface" for stdlib. (#25640)

The stdlib testing package now includes this interface, so we can
remove our dependency on the external library.
This commit is contained in:
James Rasell
2025-04-14 07:43:49 +01:00
committed by GitHub
parent d293684d3d
commit 85c30dfd1e
16 changed files with 44 additions and 47 deletions

View File

@@ -10,7 +10,6 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-rootcerts v1.0.2
github.com/mitchellh/go-testing-interface v1.14.1
github.com/mitchellh/mapstructure v1.5.0
github.com/shoenig/test v1.12.1
)

View File

@@ -21,8 +21,6 @@ github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5O
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

View File

@@ -22,11 +22,11 @@ import (
"net/http"
"os"
"os/exec"
"testing"
"time"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/nomad/api/internal/testutil/discover"
testing "github.com/mitchellh/go-testing-interface"
"github.com/shoenig/test/must"
"github.com/shoenig/test/wait"
)
@@ -105,7 +105,7 @@ type ServerConfigCallback func(c *TestServerConfig)
// defaultServerConfig returns a new TestServerConfig struct pre-populated with
// usable config for running as server.
func defaultServerConfig(t testing.T) *TestServerConfig {
func defaultServerConfig() *TestServerConfig {
ports := PortAllocator.Grab(3)
logLevel := "ERROR"
@@ -142,7 +142,7 @@ func defaultServerConfig(t testing.T) *TestServerConfig {
type TestServer struct {
cmd *exec.Cmd
Config *TestServerConfig
t testing.T
t testing.TB
HTTPAddr string
SerfAddr string
@@ -151,7 +151,7 @@ type TestServer struct {
// NewTestServer creates a new TestServer, and makes a call to
// an optional callback function to modify the configuration.
func NewTestServer(t testing.T, cb ServerConfigCallback) *TestServer {
func NewTestServer(t testing.TB, cb ServerConfigCallback) *TestServer {
path, err := discover.NomadExecutable()
if err != nil {
t.Skipf("nomad not found, skipping: %v", err)
@@ -167,7 +167,7 @@ func NewTestServer(t testing.T, cb ServerConfigCallback) *TestServer {
configFile, err := os.CreateTemp(dataDir, "nomad")
must.NoError(t, err)
nomadConfig := defaultServerConfig(t)
nomadConfig := defaultServerConfig()
nomadConfig.DataDir = dataDir
if cb != nil {