You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 not sure the best way to address this, but here's the problem.
because
Execute()
eventually callsexitFunction
which defaults toos.Exit
themain()
function pattern as used in the template plugin github projects are very difficult to test usinggo test
What happens is
main()
will exit the test entirely unless you setexitFunction
, but exitFunction isn't exposed as a tunable.I'm able to work-around this using
reflect
andunsafe
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.
The text was updated successfully, but these errors were encountered: