0

I'm writing integration tests for a Go program that queries a MongoDB cluster using Mongo Go Driver. I'd like to record those requests and later replay them in the tests.

Is there a library that I could use? I'm currently familiar with 2 similar libraries, but those are used for different purposes:

Any help would be appreciated. Thank you.

  • why don't you use setProfilingLevel? https://stackoverflow.com/q/15204341/9391162 – AMK Aug 25 '23 at 09:23
  • see my answer here https://stackoverflow.com/a/69902182/9492730. Mongo drivers allow subscription on events that happens in the driver.In particular `CommandSucceededEvent` event happens when the command successfully has been sent to the server – dododo Aug 25 '23 at 09:42
  • recent driver releases should allow logging, see here https://www.mongodb.com/docs/drivers/go/current/fundamentals/logging/ – dododo Aug 25 '23 at 09:43
  • as for replaying, I'm not sure I understand your goal, but you can run any raw MQL query (for example recorded via events) via runCommand, see here https://www.mongodb.com/docs/drivers/go/current/fundamentals/run-command/. – dododo Aug 25 '23 at 09:46

0 Answers0