Open assapir opened 6 years ago
If this is a way to simulate failure, I agree having this would be awesome. Something to have commands (findOne
, updateMany
, etc...) to fail and throw, to ensure error handling is properly implemented.
@meijin007 Could you confirm this is what you were referring to ? Thanks.
Yes, this is what I was referring to
@williamkapke Any update or any thought on that ? Thanks.
I wonder if you can accomplished it with https://www.npmjs.com/package/proxyquire?
Otherwise- I'm sure something could be worked out. Can you give example code of how you hope for the feature to work?
A very simple approach could be a way to set a flag that would make all subsequent requests to throw, like in case of network error, or DB process down (which is probably the same).
Different flags could be used to throw different kind of errors, again, network, data corruption or else, sorry I'm familiar with all MongoDB errors, the most I know are network errors.
The goal is to test what happens when my code can properly connect and start to do things, but then at a random point in time, no more network. Does all my code is correctly resilient to failure, this is the best way to test it.
Thank you for pointing proxyquire by the way, but I don't think it's going to help in this scenario. This failure simulation feature needs to come from within I believe.
Can you add more description around this? Maybe an example of an expected input and output, or else I feel like this should be closed.