Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1186

Export SingleResult fields

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Testing
    • None

      All fields on SingleResult are not exported, which makes really hard to mock a FindOne request.

      For testing I've declared some interfaces, which let me use a mock instead of the driver.

      ```
      type MongoCollection interface {
      InsertOne(ctx context.Context, document interface{},
      opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
      FindOne(ctx context.Context, filter interface{},
      opts ...*options.FindOneOptions) *mongo.SingleResult
      DeleteOne(ctx context.Context, filter interface{},
      opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
      }
      ```

      I can use mockgen to create a mock, but then I cannot create a fake `SingleResult`, only an empty one which only let me test an error situation.

      Having the fields exported would let me test this easily.

            Assignee:
            Unassigned Unassigned
            Reporter:
            pedro.kiefer Pedro Kiefer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: