-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Related to #103, but with the difference, that i'm ok with having the fake in a sub-package (omitting -o flag)
package abc
//go:generate $GOPATH/src/github.com/maxbrunsfeld/counterfeiter/counterfeiter . Foo
// some struct which the implementer of the interface should return
type Stuff struct{}
type Foo interface {
Bar() Stuff
}I write a test file in the same package abc
package abc
import (
"testing"
"github.com/where/is/abc/abcfakes"
)
func Test_SomethingInteractingWithFoo(t *testing.T) {
// fmt.Println("some stuff happens before")
fakeFoo := &abcfakes.FakeFoo{}
// fmt.Println("some stuff happens after")
}once generated, abcfakes/fake_foo.go has these lines:
// Code generated by counterfeiter. DO NOT EDIT.
package abcfakes
import (
"sync"
"github.com/where/is/abc"
)
// ...
func (fake *FakeFoo) Bar() (abc.Stuff) {
// and for any other method using a type from the package
// ...
}
// ...
var _ abc.Foo = new(FakeFoo)-
So, first problem is the same as in Interface fakes generated in the same package as the interface cause an import cycle #103.
var _ abc.Foo = new(FakeFoo)forces theFakeFoofile to importgithub.1485827954.workers.dev/where/is/abcwhich causes an import cycle, because coming fromabci'm importinggithub.1485827954.workers.dev/where/is/abc/abcfakes. -
Independent of the first problem, we have still another one:
func (fake *FakeFoo) Bar() (abc.Stuff) { ... }forces theFakeFoofile to importgithub.1485827954.workers.dev/where/is/abctoo, which causes an import cycle for the same reason.