Closed kirk-anchor closed 6 months ago
Does using source mode help? https://github.com/golang/mock/issues/297
I am using source mode. It will generate a MockgenericBatch
struct that is a mock of the interface but the MockQuerier
struct still has Batch and Scan methods with batch genericBatch
as an arg, which does not exist. If I manually modify the mock methods to use an arg batch MockgenericBatch
then the mock struct won't satisfy the Querier
interface because it expects to have Batch and Scan methods with an arg for the unexported batch genericBatch
interface.
It would work fine for generating mocks within the same package but I would like the generated mocks to be in a separate package. A couple options would be to make genericBatch
exported, i.e. GenericBatch
. Or an option to skip generating batch methods. I am using batch queries but only 3 or 4 per batch so disabling batching and using non-batched queries in a transaction would be fine. I can create a pull request if you approve of one of these options.
Fixed after batch queries were removed in https://github.com/jschaf/pggen/pull/93
I am trying to use GoMock to generate a mock for the pggen
Querier
interface. https://github.com/golang/mockThe problem is the struct generated by mockgen cannot have methods with the unexported
genericBatch
interface as params on the mockedBatch
andScan
methods. I tried copying thegenericBatch
into the mock package and while that makes the methods on the struct work, the struct does not satisfy theQuerier
interface anymore because theQuerier
interface expects the methods to have its package's unexportedgenericBatch
interface.Shouldn't we be able to mock the
Querier
interface?