[GODRIVER-2249] Investigate alternative solutions for mocking main API types Created: 01/Dec/21  Updated: 07/Dec/23

Status: Scheduled
Project: Go Driver
Component/s: Testing
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Benji Rewis (Inactive) Assignee: Matt Dale
Resolution: Unresolved Votes: 0
Labels: rp-track
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-1241 Mocking library Closed
is related to GODRIVER-834 Please convert Client, Database, Coll... Closed

 Description   

Requests to convert our main API types (Collection, Database, Client, etc.) to interfaces instead of basic structs are continuing to come in. It's clear that users desire a more seamless way of mocking the behavior of the Go driver for their own testing. See related tickets and online discussions (GODRIVER-2161, GODRIVER-1241, GODRIVER-834, community forum posts, and comments on our PRs).

For reasons of backwards-compatibility (usually, any additions to Go interfaces require major releases under SemVer) and Go best practices (Go official documentation advises against returning interfaces in the "implementer API"), we are against converting the structs to interfaces. But, we should really investigate alternative solutions here and think about ways to ease this user burden.



 Comments   
Comment by Rachelle Palmer [ 07/Dec/23 ]

More requests on this topic from users:
Please Make the Go driver interface based so that it can be easily mocked for unitTests and provide interfaces for driver classes that can be used to mock the database for unit tests. Along the lines of what AWS does for its services:
https://aws.amazon.com/blogs/developer/mocking-out-then-aws-sdk-for-go-for-unit-testing/

Generated at Thu Feb 08 08:38:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.