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

Unexported function on the Transport interface prevents mocking #104

Open
DominicLavery opened this issue Dec 1, 2022 · 1 comment · May be fixed by #109
Open

Unexported function on the Transport interface prevents mocking #104

DominicLavery opened this issue Dec 1, 2022 · 1 comment · May be fixed by #109

Comments

@DominicLavery
Copy link

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
Copy link
Author

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.

bjohnso5 added a commit to CircleCI-Public/rollbar-go that referenced this issue Apr 4, 2024
@bjohnso5 bjohnso5 linked a pull request Apr 4, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant