I try to create a mock of a file with an interface imported from another file. I have try with `aux_files` and `imports` but I did non succeed to have a correct mock file. I think I'm missing something.
So I have a `mockgen/main.go` like this :
package main
import (
"log"
o "mockgen/otheri"
)
type bar struct {
a o.Foo
}
func NewBar(a o.Foo) *bar {
return &bar{a}
}
func main() {
var t = NewBar(&o.FunctionStuct{})
if err := t.a.Ask(); err != nil {
log.Fatal(err)
}
}
And the interface imported is in `mockgen/otheri/otheri.go` :
package otheri
import "log"
type Foo interface {
Ask() error
}
type FunctionStuct struct {
}
func (f *FunctionStuct) Ask() error {
log.Println("Hello")
return nil
}
The command I tried is :
mockgen -source main.go -aux_files o=otheri/otheri.go
executed at the same level as the main.go
But my mockgen file is empty....
Does anyone has an idea ? My goal is to mock the interface o.Foo
contains in main.go me without changing my architecture
I need to mock it to test it with unit tests.
The architecture is like this because I follow clean architecture.
Thanks for all