-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add support in Snap.Snaplet.Test for reusing initializers. #105
Conversation
- expose getSnaplet helper that returns a Snaplet and InitializerState and expose the InitializerState type - add closeSnaplet to run cleanup, to be used after all tests have been run. - add evalHandler' and runHandler' that take Snaplet and InitializerState and otherwise parallel evalHandler and runHandler
|
||
------------------------------------------------------------------------------ | ||
-- | Helper to allow multiple calls to "runHandler" or "evalHandler" without | ||
-- multiple initializations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quibble: add a period at the end of the docstring sentence
Could you please add tests for the new methods to the testsuite? |
@gregorycollins Just to check, there aren't any existing tests for Snap.Snaplet.Test, right? I poked around, but don't want to add a new file if there is an existing place to put them. |
We should be using this module to test the other modules. The important thing is to check the test coverage report and ensure the functions are covered, it doesn't matter too much where the tests go. |
The snap test suite is a little bit scattered because most of it was written before we had the Snaplet.Test module. So feel free to use these functions to replace any of our other tests if there are good places to do that. |
I've added tests for the new functions and the old ones (the old ones were getting coverage via usage for Auth tests, but I thought it made sense to put in basic tests for them as well). The tests are pretty basic, but the functions aren't doing a whole lot, either. |
Add support in Snap.Snaplet.Test for reusing initializers.
This allows for much more efficient testing libraries, as initializing can take a while, and if you want to run many tests, currently you have to pay that startup time for each runHandler/evalHandler.
The only question I had was whether to wrap InitializerState inside an opaque type (so it could only be used with the functions in this module). I didn't, but can make that change if it is preferred.