Closed hashcacher closed 5 years ago
Hi Greg,
mockgen can only create mocks from Interfaces.
If the system under test takes a struct then it can't be mocked out because the Go type system will only accept that struct as an argument.
If the system under test takes an Interface implemented by your struct then it can take a mock that also implements that Interface.
In other words:
What would you like mockgen to generate from the structs?
Hesky
Hey Hesky,
I ran it on another file and mis-read the output. I thought it generated a mock struct and interface but on second glance, it only mocked a struct for the existing interface. Perhaps if I write an interface with all the methods of the consul classes that I need to call, then it could generate mocks for those? In an ideal world, it would automatically write the interface too :)
Go Version: 1.12.1
Consul has a deep nested struct hierarchy that would be delightful to not mock manually. I think I've tried most of the permutations of options and files. Here's the repo: https://github.com/hashicorp/consul/tree/master/api
I tried -source
All output the same nearly blank file:
I also tried using reflection:
outputs
I'll also mention that it works great for some other (simpler) files, so it doesn't seem like a setup issue.
Thanks in advance!