minimock
minimock copied to clipboard
Mocks aren't generated for type aliases
Due to AST interpreting interface aliases as aliases, and not as interfaces, minimock skips interface aliases and doesn't generate mocks for them.
For testing it out I used the latest version of minimock cloned directly from this repository.
Here are the steps to reproduce:
- Create a file, for example,
./example/types.go
- Fill it with the following contents:
package example
import "io"
type Sampler interface {
Sample()
}
type Sampler2 Sampler
type Sampler3 = Sampler
type ReaderAlias io.Reader
type ReadWriteSeekCloser interface {
io.ReadWriteCloser
io.Seeker
}
- Run generation command:
minimock -i "./example.*"
I expect all five interfaces to be generated, but only the first one and the last one is generated, which we can see from the command output:
$ go run ./cmd/minimock -i "./example.*"
minimock: ./sampler_mock_test.go
minimock: ./read_write_seek_closer_mock_test.go