diff --git a/client_test.go b/client_test.go index 152f40ca1..d164dd6f7 100644 --- a/client_test.go +++ b/client_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" pkgErrors "github.com/pkg/errors" + "github.com/stretchr/testify/require" ) func TestNewClientAllowsEmptyDSN(t *testing.T) { @@ -609,6 +610,7 @@ func TestSampleRate(t *testing.T) { func BenchmarkProcessEvent(b *testing.B) { c, err := NewClient(ClientOptions{ SampleRate: 0.25, + Transport: &TransportMock{}, }) if err != nil { b.Fatal(err) @@ -708,8 +710,17 @@ func TestCustomMaxSpansProperty(t *testing.T) { assertEqual(t, client.Options().MaxSpans, 2000) properClient, _ := NewClient(ClientOptions{ - MaxSpans: 3000, + MaxSpans: 3000, + Transport: &TransportMock{}, }) assertEqual(t, properClient.Options().MaxSpans, 3000) } + +func TestClientSetsUpTransport(t *testing.T) { + client, _ := NewClient(ClientOptions{Dsn: testDsn}) + require.IsType(t, &HTTPTransport{}, client.Transport) + + client, _ = NewClient(ClientOptions{}) + require.IsType(t, &noopTransport{}, client.Transport) +} diff --git a/hub_test.go b/hub_test.go index 23ae3746f..46b889774 100644 --- a/hub_test.go +++ b/hub_test.go @@ -13,7 +13,7 @@ import ( const testDsn = "http://whatever@example.com/1337" func setupHubTest() (*Hub, *Client, *Scope) { - client, _ := NewClient(ClientOptions{Dsn: testDsn}) + client, _ := NewClient(ClientOptions{Dsn: testDsn, Transport: &TransportMock{}}) scope := NewScope() hub := NewHub(client, scope) return hub, client, scope @@ -95,7 +95,7 @@ func TestPopScopeCannotLeaveStackEmpty(t *testing.T) { func TestBindClient(t *testing.T) { hub, client, _ := setupHubTest() hub.PushScope() - newClient, _ := NewClient(ClientOptions{Dsn: testDsn}) + newClient, _ := NewClient(ClientOptions{Dsn: testDsn, Transport: &TransportMock{}}) hub.BindClient(newClient) if (*hub.stack)[0].client == (*hub.stack)[1].client { @@ -123,7 +123,7 @@ func TestWithScopeBindClient(t *testing.T) { hub, client, _ := setupHubTest() hub.WithScope(func(scope *Scope) { - newClient, _ := NewClient(ClientOptions{Dsn: testDsn}) + newClient, _ := NewClient(ClientOptions{Dsn: testDsn, Transport: &TransportMock{}}) hub.BindClient(newClient) if hub.stackTop().client != newClient { t.Error("should use newly bound client") diff --git a/tracing_test.go b/tracing_test.go index 5bb0e364b..61848cb0a 100644 --- a/tracing_test.go +++ b/tracing_test.go @@ -362,6 +362,9 @@ type testContextKey struct{} type testContextValue struct{} func NewTestContext(options ClientOptions) context.Context { + if options.Transport == nil { + options.Transport = &TransportMock{} + } client, err := NewClient(options) if err != nil { panic(err)