I was talking with @lostkobrakai who gave me some great advice on Slack earlier and I thought I’d get some community input on this topic to see where everyone else is at. Basically, having followed the practices in Programming Phoenix 1.2, my app has a
Posts model and two test files for it, one for repo tests and one with tests which don’t touch the DB. These tests mostly just tested the
Post.changeset function to make sure it could handle valid data, gave
unique_constraint errors for slugs which match other slugs, and things like that. However, now that I’m refactoring for 1.3 I feel that i should only be testing functions from my new
Posts context. The only problem with that is that I basically have to duplicate all the tests for
update_post, instead of testing the changeset as a unit once, because those both hit the changeset and thats what I’m really testing.
So, people on 1.3, do you unit test the changeset itself of just the context functions?
Thanks all, I’m not super experienced with Phoenix (especially 1.3)