Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock file not valid for generic interfaces #100

Open
ehsandavari opened this issue Oct 4, 2023 · 4 comments
Open

mock file not valid for generic interfaces #100

ehsandavari opened this issue Oct 4, 2023 · 4 comments

Comments

@ehsandavari
Copy link

ehsandavari commented Oct 4, 2023

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

@r-hang
Copy link
Contributor

r-hang commented Oct 10, 2023

I believe this is a duplicate of #97

@ehsandavari
Copy link
Author

this bug fixed in #98
When will you merge this branch?

@pckhoi
Copy link

pckhoi commented Oct 27, 2023

In the mean time, running mockgen in source mode is working pretty well for me.

@bcho
Copy link
Contributor

bcho commented Nov 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants