gojuno / minimock

Powerful mock generation tool for Go programming language
MIT License
577 stars 38 forks source link

go:generate from files generated with the -o parameter is broken #53

Closed sm4ll-3gg closed 6 months ago

sm4ll-3gg commented 3 years ago

Let's imagine that we have an interface e.g. Fooer in the /internal/pkg/fooer directory. We want to generate mocks for it. So we run minimock -i ./internal/pkg/fooer.Fooer -o internal/pkg/fooer to get a fooer_mock_test.go generated near the tests files.

In the generated file we have go:generate comment: //go:generate minimock -i github.com/org/project/internal/pkg/fooer.Fooer -o ./internal/pkg/fooer/fooer_mock_test.go

Now we want to regenerate the code using go generate ./... in the project root, but it fails with:

minimock: stat internal/pkg/fooer: no such file or directory
fooer_mock_test.go:5: running "minimock": exit status 1

This is because the command in the go:generate comment should contains -o ./fooer_mock_test.go without the ./internal/pkg/fooer prefix so that the generated code is placed in the same directory that it is now.

Is it a bug or am I doing something wrong?

hexdigest commented 6 months ago

Hey @sm4ll-3gg

This should be fixed in 3.2.2

hexdigest commented 6 months ago

Feel free to re-open if you find any problems

webornottoweb commented 4 months ago

Nope. This still doesn't work. Nor 3.2.2 nor 3.3.6. Same error