sensu / sensu-influxdb-handler

Sensu Go InfluxDB Metrics Handler
https://sensu.io
MIT License
14 stars 16 forks source link

update testing of Execute to use non-default exitFunction #41

Open jspaleta opened 3 years ago

jspaleta commented 3 years ago

Due to the way the plugin sdk operates, the handler's Execute function will call os.Exit by default as part of Execute()

This makes it impossible to test state after Execute() is called from main() in the test used in TestMain.

I've addressed this by changing the testing structure tp test Execute explicitly and setting a non-default exitFunction to capture the exit status integer instead of calling os.Exit

previous TestMain never actually reached the assert.True(requestReceived) statement because main() was calling os.Exit