Mongodb-memory-server for rust?

Hi, I have previously used this library mongodb-memory-server in a nodejs project and liked how I could write unit tests that just got fake data from a fake db without me having to mock the mongo lib functions...

I am now working on a project using the rust-mongo-driver and am in need of something like this for those unit tests!!

Can I use this npm package directly with cargo testing?

Is there something similar for Rust?

Thanks! :pray:

It would add an extra dependency on NodeJS, but there's nothing stopping you from writing a simple JS script that starts the server and waits for a signal to stop (e.g. ctrl-C).

Your Rust code would then need to make sure the script is started whenever you run a test and stopped when the text exits (e.g. you could create a RAII guard which spawns the subprocess in its constructor and kills it on drop).

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.