I have a Phoenix application that is provides a standard REST API. I currently have two models and am looking at unit-testing. One of my controller’s unit tests is passing fine, but the other is showing some off behaviour in the update and create tests.
- Update with valid data isn’t updating the data and returns
{"errors":{"comment":["can't be blank"],"control":["can't be blank"],"value":["can't be blank"]}}
- Update with invalid data isn’t erroring and returning the entry
- Create with valid data is doing what the invalid case should do and returning 422 with
{"errors":{"comment":["can't be blank"],"control":["can't be blank"],"value":["can't be blank"]}}
These are generated tests, as are those for the other controller which are working fine. I’d be OK with this if the controller wasn’t working as expected, but when running the queries manually from a REST client, the application behaves as expected in all three cases.
Here’s the
- unit test https://www.paste.in/aIwZpZ
- Controller https://www.paste.in/LFb2CW
- Model https://www.paste.in/XFpqij
Note that I have dropped the ["data"]
part of the response. This is the case for the other controller too, where the tests are passing fine.