Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1891

Implement Default on result structs for mocking

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.3.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Rust Drivers
    • Not Needed

      Hi team,

      I've been working with the MongoDB Rust driver and had an idea I wanted to run by you. The use of #[non_exhaustive] on structs is super helpful for future-proofing the library. It’s a smart move for sure.

      But, this does make unit testing and mocking a bit of a challenge. To test a function that returns a DB response, we first have to create a matching record in the DB (we're using Docker for testing), which introduces additional dependencies and overhead in what should be pretty simple unit tests. 

      What if we add the Default trait to key structs, specifically those located inside `mongodb::results`? This way, we can instantiate these structs with defaults for testing without messing with the benefits of #[non_exhaustive]

      Thank you!

      Ulises Himely

            Assignee:
            isabel.atkinson@mongodb.com Isabel Atkinson
            Reporter:
            ulises.himely@elevationchurch.org Ulises Himely
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: