-
Notifications
You must be signed in to change notification settings - Fork 441
Open
Description
Description
There are two bugs when using replace-type for pointer parameters
- paramPkgPath and paramObjName are empty string if the signature param is types.Pointer, causing the following ifaceConfig.GetReplacement function doesn't return the replace-type from the config.
- Assuming the correct replace-type can be retrieved, the replaced type will be loaded here and since it is not types.Pointers, the following types.TypeString() wouldn't add
*
at the beginning.
If you reckon these bugs are valid, I am happy to raise a PR to fix them, since I have made potential fix on my local.
Reproducer
- Create an interface that including temporal schedule in a project.
type ScheduleHandle interface {
client.ScheduleHandle
}
- Copy the following config to
.mockery.yaml
dir: '{{.InterfaceDir}}/mocks'
structname: '{{.InterfaceName}}'
pkgname: mocks
filename: "{{.InterfaceName}}.go"
template: testify
log-level: debug
template-data:
unroll-variadic: true
packages:
mockery-bug/internal:
interfaces:
ScheduleHandle:
config:
replace-type:
go.temporal.io/sdk/internal:
ScheduleBackfillOptions:
pkg-path: go.temporal.io/sdk/client
type-name: ScheduleBackfillOptions
SchedulePauseOptions:
pkg-path: go.temporal.io/sdk/client
type-name: SchedulePauseOptions
ScheduleTriggerOptions:
pkg-path: go.temporal.io/sdk/client
type-name: ScheduleTriggerOptions
ScheduleUnpauseOptions:
pkg-path: go.temporal.io/sdk/client
type-name: ScheduleUnpauseOptions
ScheduleUpdateOptions:
pkg-path: go.temporal.io/sdk/client
type-name: ScheduleUpdateOptions
ScheduleDescription:
pkg-path: go.temporal.io/sdk/client
type-name: ScheduleDescription
- run
mockery
, and check the generated file ScheduleHandle.go, the imports for all other structs have been correctly replaced frominternal
toclient
, exceptScheduleDescription
in theDescribe
method.
Expected behavior
The return value *internal.ScheduleDescription
is supposed to be *client.ScheduleDescription
.
Mockery version
v3.5.1
Installation Mechanism
- []
go get
- [] Pre-built release
- [] homebrew
- [] Other
Go version
1.24
Kkye
Metadata
Metadata
Assignees
Labels
No labels