rollbar / rollbar-go

Go client for Rollbar
https://docs.rollbar.com/docs/go
MIT License
105 stars 23 forks source link

Unexported function on the Transport interface prevents mocking #104

Open DominicLavery opened 1 year ago

DominicLavery commented 1 year ago

In v1.4.5 the Transport interface gained the unexported function setContext(ctx context.Context). This prevents it from being mocked in projects that want to add tests that confirm the library is being used correctly.

This is done in a similar way to the TestTransport in client_test.go. Trying to define a similar struct in another project will result in the following error (regardless of whether the new function is defined or not)

cannot use transport (variable of type *mock.TestTransport) as type "github.com/rollbar/rollbar-go".Transport in assignment:
    *mock.TestTransport does not implement "github.com/rollbar/rollbar-go".Transport (missing setContext method)
DominicLavery commented 1 year ago

I'd be happy to raise a PR for this which simply exports setContext(ctx context.Context), but I am unsure if it is suitable for being exported.