Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export SetContext to support mocking Transport #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion async_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (t *AsyncTransport) Close() error {
return nil
}

func (t *AsyncTransport) setContext(ctx context.Context) {
func (t *AsyncTransport) SetContext(ctx context.Context) {
t.ctx = ctx
}

Expand Down
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewAsync(token, environment, codeVersion, serverHost, serverRoot string, op
if c.ctx == nil {
c.ctx = context.Background()
}
c.Transport.setContext(c.ctx)
c.Transport.SetContext(c.ctx)
return c
}

Expand Down Expand Up @@ -98,10 +98,10 @@ func (c *Client) SetTelemetry(options ...OptionFunc) {
}
func (c *Client) SetContext(ctx context.Context) {
c.ctx = ctx
c.Transport.setContext(ctx)
c.Transport.SetContext(ctx)
}

// SetEnabled sets whether or not Rollbar is enabled.
// SetEnabled sets whether Rollbar is enabled.
// If this is true then this library works as normal.
// If this is false then no calls will be made to the network.
// One place where this is useful is for turning off reporting in tests.
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (t *TestTransport) Close() error {
func (t *TestTransport) Wait() {
t.WaitCalled = true
}
func (t *TestTransport) setContext(ctx context.Context) {
func (t *TestTransport) SetContext(ctx context.Context) {
}

func (t *TestTransport) SetToken(_t string) {}
Expand Down
2 changes: 1 addition & 1 deletion sync_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ func (t *SyncTransport) Wait() {}
func (t *SyncTransport) Close() error {
return nil
}
func (t *SyncTransport) setContext(ctx context.Context) {
func (t *SyncTransport) SetContext(ctx context.Context) {
}
6 changes: 3 additions & 3 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type transportOption func(Transport)

func WithTransportContext(ctx context.Context) transportOption {
return func(t Transport) {
t.setContext(ctx)
t.SetContext(ctx)
}
}

Expand Down Expand Up @@ -51,8 +51,8 @@ type Transport interface {
SetHTTPClient(httpClient *http.Client)
// SetItemsPerMinute sets the max number of items to send in a given minute
SetItemsPerMinute(itemsPerMinute int)

setContext(ctx context.Context)
// SetContext sets the context to use for API calls made over the Transport
SetContext(ctx context.Context)
}

// ClientLogger is the interface used by the rollbar Client/Transport to report problems.
Expand Down
Loading