yesodweb/yesod-scaffold

Feature proposal: wipe database between tests in scaffolding

Closed this issue · 5 comments

I was talking with @bitemyapp and we both thought that'd it be nice if the scaffolding came with code to wipe the database between tests. Imo, that behavior is pretty foundational to a test suite.

I don't think its super complicated to write such behavior; this is an implementation for SQLite. All of the SQL databases have different queries for getting the list of tables/truncating those tables, but they're similar in structure. MongoDB and Redis are easier to wipe.

Anyway, I'm interested in developing this but didn't know if you felt it fit a) in the scaffolding or b) as an external package included by the scaffolding or c) as an external package not included by the scaffolding.

@MaxGabriel A lot of the problem, at least for me, was just getting an explicit main.hs that worked for the test runner. I realize this sort of thing is trivial for smarties, but sparing a thought for us dumb people would be appreciated.

In the scaffolding is good. I have code for this that I should find this weekend.

@gregwebs having an explicit test runner is all I really wanted for the default scaffolding. Test database state reset would be icing on the cake.

Closing this because database wiping is implemented in all the backends.

And thank you for that :)