Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Mockgen imports not working #13

Closed
gudladona opened this issue Nov 24, 2015 · 3 comments
Closed

Mockgen imports not working #13

gudladona opened this issue Nov 24, 2015 · 3 comments

Comments

@gudladona
Copy link

mockgen with Imports flag does not generate the mocked file correctly.

mockgen -source ../iam/types/apis.go -destination cmd/iam_mock.go -package iam -imports iamTypes=git.nexgen.neustar.biz/IAS/iam/types

// Automatically generated by MockGen. DO NOT EDIT!
// Source: ../iam/types/apis.go

package iam

import (
gomock "github.com/golang/mock/gomock"
)

// Mock of UserApi interface
type MockUserApi struct {
ctrl *gomock.Controller
recorder *_MockUserApiRecorder
}

// Recorder for MockUserApi (not exported)
type _MockUserApiRecorder struct {
mock *MockUserApi
}

func NewMockUserApi(ctrl *gomock.Controller) *MockUserApi {
mock := &MockUserApi{ctrl: ctrl}
mock.recorder = &_MockUserApiRecorder{mock}
return mock
}

func (_m *MockUserApi) EXPECT() *_MockUserApiRecorder {
return _m.recorder
}

func (_m *MockUserApi) CreateUser(user IAMUser) (IAMUser, error) {
ret := _m.ctrl.Call(_m, "CreateUser", user)
ret0, _ := ret[0].(IAMUser)
ret1, _ := ret[1].(error)
return ret0, ret1
}

func (_mr *_MockUserApiRecorder) CreateUser(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "CreateUser", arg0)
}

// Mock of OrganizationApi interface
type MockOrganizationApi struct {
ctrl *gomock.Controller
recorder *_MockOrganizationApiRecorder
}

// Recorder for MockOrganizationApi (not exported)
type _MockOrganizationApiRecorder struct {
mock *MockOrganizationApi
}

func NewMockOrganizationApi(ctrl *gomock.Controller) *MockOrganizationApi {
mock := &MockOrganizationApi{ctrl: ctrl}
mock.recorder = &_MockOrganizationApiRecorder{mock}
return mock
}

func (_m *MockOrganizationApi) EXPECT() *_MockOrganizationApiRecorder {
return _m.recorder
}

func (_m *MockOrganizationApi) CreateOrganization(org IAMOrganization) (IAMOrganization, error) {
ret := _m.ctrl.Call(_m, "CreateOrganization", org)
ret0, _ := ret[0].(IAMOrganization)
ret1, _ := ret[1].(error)
return ret0, ret1
}

func (_mr *_MockOrganizationApiRecorder) CreateOrganization(arg0 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "CreateOrganization", arg0)
}

@dsymonds
Copy link
Contributor

Can you be more specific? What's generated incorrectly?

Does it work better in "reflect mode"? (run mockgen -help)

@gudladona
Copy link
Author

Even after i specify the "-imports iamTypes=git.nexgen.neustar.biz/IAS/iam/types" in import flag it does not generate/include the import. I did not understand the usage of "reflect mode". Could you please give me an example of the usage ?

@gudladona
Copy link
Author

Understood the usage of reflect mode. Mocks are generated correctly. Closing the issue.

Example Usage for my case:

mockgen -package=cmd -destination=cmd/iam_mock.go git.nexgen.neustar.biz/IAS/iam/types UserApi,OrganizationApi

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

No branches or pull requests

2 participants