mockery
mockery copied to clipboard
Generate private interface doesn't work
i'm using mockery version 2.7.4, and i have a private interface:
type elasticsearchRequest interface {
Do(ctx context.Context, transport esapi.Transport) (resp *esapi.Response, err error)
}
what i did : mockery --exported --name=elasticsearchRequest
generated file still use private interface
// Code generated by mockery v2.7.4. DO NOT EDIT.
package mocks
import (
context "context"
esapi "github.com/elastic/go-elasticsearch/v7/esapi"
mock "github.com/stretchr/testify/mock"
)
// elasticsearchRequest is an autogenerated mock type for the elasticsearchRequest type
type elasticsearchRequest struct {
mock.Mock
}
...
I am experiencing this as well
Edit: found the root cause, it's because of this: https://github.com/vektra/mockery/blob/9ee1699711f8856a7c20bd9872cd39b3750ffa74/pkg/generator.go#L200 Using the --in-package flag with --exported works. Seems like a bug
Bump
I hope that this issue will be resolved by the granular level of control the packages configuration feature gives you. Please give that a shot and let me know if it doesn't work.