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 |
---|---|---|---|
Working with timezones and $dateTrunc | 3 | 493 | Apr 2024 |
Facing issue in using a schema in two microservices | 3 | 316 | Jun 2024 |
Installing kafka with k raft | 0 | 361 | Jun 2024 |
How to configure the timeout on the user level in mongo on linux i.e., restrict user for running query more than a min by default without they mention maxTimeMS, Want to configure for all read access user | 0 | 24 | Sep 2024 |
Looking for help in aggregating user orders data | 12 | 165 | Feb 10 |