Closed QuantumBJump closed 4 years ago
Can you please share a repo or zip file with which I can reproduce the issue? I tried to do so but the mock was generated correctly without any problem.
-- testmock/issue123/persistence_client.go
package issue123
import "testmock/issue123/persistence_data"
//go:generate moq -out mock_persistence_data_test.go . persistenceClient
type persistenceClient interface {
EnsureSchema()
GetUnfinishedSchedules() (*[]persistence_data.ScheduleRequest, error)
}
-- testmock/issue123/persistence_data/schedule_req.go
package persistence_data
type ScheduleRequest int
testmock/issue123/mock_persistence_data_test.go
Ok, it looks like I've managed to fix the issue, although I don't know why the problem was happening or why what I did fixed it - I had a shell script running whenever I made a merge request to my project, which ran go get moq
, generated the mocks and ran the tests.
For some reason this started failing at some point (although I didn't make any changes relating to that part of the codebase), and the solution was to remove the go get github.com/matryer/moq
call from the shell script, as the computer running it already had moq installed. My best guess is that maybe it was the fact it was being run in the project source directory itself might have been a problem? That or the fact that my project uses go modules and I don't think moq does... Either way, this problem seems to be resolved (if unsatifactorily) for my use case.
I have an interface in one of my packages with the structure
Recently, moq has suddenly started panicking whenever I try to run
go generate
, and I can't work out why. I have managed to work out that it only happens when there's a function in the mocked interface which returns a type imported from a different package, but I can't work out why it's a problem. The error messages in themselves are unhelpful - I get ago/format: expected ), got type
error, followed by the moq usage string, followed byrunning "moq": exit status 1
It's starting to look like our only option is to refactor the entire program to not use moq any more, which is something I'm loathe to do...