mock file not valid for generic interfaces
ehsandavari opened this issue · 6 comments
ehsandavari commented
in generic use pkg path in line of code like
import (
context "context"
gomock "go.uber.org/mock/gomock"
gorm "gorm.io/gorm"
reflect "reflect"
entity "wallet-core/domain/entity"
genericRepository "wallet-core/pkg/genericRepository"
)
func (m *MockIBaseWalletTemplateRepository) Paginate(arg0 context.Context, arg1 *genericRepository.PaginateQuery) (genericRepository.IPaginateResult[wallet-core/domain/entity.BaseWalletTemplate], error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Paginate", arg0, arg1)
ret0, _ := ret[0].(genericRepository.IPaginateResult[wallet-core/domain/entity.BaseWalletTemplate])
ret1, _ := ret[1].(error)
return ret0, ret1
}
bug is : wallet-core/domain/entity.BaseWalletTemplate in return of paginate func mock
I fix bug with use this
parts := strings.Split(t, "/")
t = parts[len(parts)-1]
in my local clone project in path mockgen/mockgen.go in top of line 588 and test code with unit tests
ehsandavari commented
this bug fixed in #98
When will you merge this branch?
pckhoi commented
In the mean time, running mockgen in source mode is working pretty well for me.
bcho commented
I don't have time to continue my fix yet. Using source mode can help work around the issue since it runs on AST level.