guibou / krank

Krank checks your code source comments for important markers
BSD 3-Clause "New" or "Revised" License
21 stars 3 forks source link

Infrastructure changes to improve the test story #52

Closed guibou closed 4 years ago

guibou commented 4 years ago

With theses change, the code executed to run a rest request is configurable. It means that we can now run test with stub request (not yet done).

For example, we can now write a request function for tests like:

runRequestForTests url headers = pure $ AesonBool True

or

runRequestForTests url headers = throwIO $ VanillaHttpException ...

I'm having second thoughts with this solution, so @gbataille if you can discuss it I'll be really happy.

This solution is great because:

This solution sucks because:

I can also add something for readFile and putStrLn in the configuration. This way krank will still live in IO, but everything will use customization functions and will be fully testable.

Another solution may be to move to a full "effect" library pattern. However I can see the following effects, currently managed by IO, but that which will need to be detailed:

It will be a more important change, which can take the following shape:

guibou commented 4 years ago

Deprecated in favor of #55 which fixes all the discussed problem by introducing a custom monad for effect handling without being too complex to read.