minimock icon indicating copy to clipboard operation
minimock copied to clipboard

Mocks aren't generated for type aliases

Open Wani4ka opened this issue 8 months ago • 5 comments

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:

  1. Create a file, for example, ./example/types.go
  2. 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
}
  1. 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

Wani4ka avatar Jun 04 '24 19:06 Wani4ka