[GODRIVER-1186] Export SingleResult fields Created: 03/Jul/19 Updated: 29/Oct/21 Resolved: 08/Jul/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Testing |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Pedro Kiefer | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
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. ``` 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. |
| Comments |
| Comment by Kristofer Brandow (Inactive) [ 08/Jul/19 ] |
|
Hi pedro.kiefer, We generally don't recommend mocking types that you don't own and suggest that users write database abstraction layers. We recommend using integration tests if you want to test the types from the mongo package. --Kris |