github.com/newrelic/newrelic-client-go@v1.1.0/internal/http/test_helpers.go (about) 1 package http 2 3 import ( 4 "net/http" 5 "net/http/httptest" 6 "testing" 7 8 mock "github.com/newrelic/newrelic-client-go/pkg/testhelpers" 9 ) 10 11 // NewTestAPIClient returns a test Client instance that is configured to communicate with a mock server. 12 func NewTestAPIClient(t *testing.T, handler http.Handler) Client { 13 ts := httptest.NewServer(handler) 14 tc := mock.NewTestConfig(t, ts) 15 16 return NewClient(tc) 17 }