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

exitFunction creates a problem for plugin testing #39

Open
jspaleta opened this issue Aug 26, 2020 · 0 comments
Open

exitFunction creates a problem for plugin testing #39

jspaleta opened this issue Aug 26, 2020 · 0 comments

Comments

@jspaleta
Copy link
Contributor

I'm not sure the best way to address this, but here's the problem.

because Execute() eventually calls exitFunction which defaults to os.Exit the main() function pattern as used in the template plugin github projects are very difficult to test using go test
What happens is main() will exit the test entirely unless you set exitFunction, but exitFunction isn't exposed as a tunable.

I'm able to work-around this using reflect and unsafe golang packages but that seems like a lot of work to support some basic testing that we need all derived plugins to be doing.
Example workaround: https://github.com/sensu/sensu-kafka-handler/blob/master/main_test.go

Straw proposal, extend the interface that exposes Execute, with a setter function for exitFunction.

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

No branches or pull requests

1 participant