News for hackers. Stuff that matters.
Re:Why use Rust on the back end? by nightpool on Monday March 20, 2023 @05:39PM (#35239152)
> But for other databases you basically have only two options: 1. setup and teardown an actual testing db 2. wrap your sqlx interfacing code in something vaguely resembling the repository pattern and create an in-memory implementation for testing. I'd call both of these options less than ideal.

Why not just BEGIN a transaction and then ROLLBACK it after every test case? That's what every other significant backend codebase (using SQL) that I've worked on does. Maybe that's what you meant by #1? Not sure why you'd want to avoid it then—it will help significantly in testing out any piece of code you have that's even slightly outside of the CRUD norms. What does Diesel do, reimplement a completely separate "testing" version for all of its SQL queries?

Re:Why use Rust on the back end? by weiznich on Tuesday March 21, 2023 @03:15AM (#35243335)
Just using a transaction that will be rolled back after each test case is exactly what diesel suggests. There is a separate function for this on diesels connection trait[1]

[1]: https://docs.diesel.rs/2.0.x/diesel/connection/trait.Connect...