Like in the title: how do you integration-test server failures that return 500 HTTP responses?
- There's a server with a
/saveendpoint that accepts files on
POSTand saves it into the server filesystem
- There's a library/dependency
Xwhich handles the file saving functionality somewhere deep on the other end of the application
Xcan fail in a number of reasons, but for this example let's say it crashes because there's no space on the disk
- We would like to throw an HTTP 500 instead of making the process crash
What do you do in this situation?
- Do you mock
Xand actually throw an error in the test?
- Do you omit these kinds of tests and just handle errors somewhere globally?
- Do you just integration test the happy paths and ignore error cases and test them in unit tests?
- Something else?
And one question that maybe answers my whole struggle:
Is testing if every possible error is returning an
HTTP 500 something you'd call overengineering or is it rather a good practice?