I need to mock a MongoDB database for unit testing. Is there a straightforward way to mock a DB to do so?
Skip to main content
Use a local mongod instance, it’s pretty lightweight. You can use something like mtools (GitHub - rueckstiess/mtools: A collection of scripts to set up MongoDB test environments and parse and visualize MongoDB log files.) to spin up and shutdown a variety of different deployment options (standalone, replica set, sharded cluster etc).
Thanks a lot Peter that’s very helpful. Is there something similar that you know of for Go?
New & Unread Topics
Topic | Replies | Views | Activity |
---|---|---|---|
Vote for Feedback: $sort should accept 0 meaning “don’t sort” | 0 | 206 | Jul 2024 |
Missing Indexes while Mongo restoration | 15 | 684 | Oct 2024 |
Won’t able to transfer data from one database to another using mongorestore tool | 0 | 26 | Oct 2024 |
Need optimization advice for querying 2 million IP ranges at high throughput (100s/sec) | 1 | 68 | Nov 2024 |
Mysterious loss of data, in a very strange manner. | 5 | 72 | Dec 2024 |