-
-
Save rgarcia/cf553169c4832543a0a9 to your computer and use it in GitHub Desktop.
mocking a vendored dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $GOPATH/src/a/vendor/b/b.go | |
package b | |
import "log" | |
type Type int | |
type Interface interface { | |
InterfaceMethod(Type) | |
} | |
type Implementation struct { | |
} | |
func (b Implementation) InterfaceMethod(Type) { | |
log.Println("in b implementation") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Automatically generated by MockGen. DO NOT EDIT! | |
// Source: b (interfaces: Interface) | |
package mock_b | |
import ( | |
b "b" | |
gomock "github.com/golang/mock/gomock" | |
) | |
// Mock of Interface interface | |
type MockInterface struct { | |
ctrl *gomock.Controller | |
recorder *_MockInterfaceRecorder | |
} | |
// Recorder for MockInterface (not exported) | |
type _MockInterfaceRecorder struct { | |
mock *MockInterface | |
} | |
func NewMockInterface(ctrl *gomock.Controller) *MockInterface { | |
mock := &MockInterface{ctrl: ctrl} | |
mock.recorder = &_MockInterfaceRecorder{mock} | |
return mock | |
} | |
func (_m *MockInterface) EXPECT() *_MockInterfaceRecorder { | |
return _m.recorder | |
} | |
func (_m *MockInterface) InterfaceMethod(_param0 b.Type) { | |
_m.ctrl.Call(_m, "InterfaceMethod", _param0) | |
} | |
func (_mr *_MockInterfaceRecorder) InterfaceMethod(arg0 interface{}) *gomock.Call { | |
return _mr.mock.ctrl.RecordCall(_mr.mock, "InterfaceMethod", arg0) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $GOPATH/src/a/main.go | |
package main | |
import "b" | |
func main() { | |
bobj := b.Implementation{} | |
var btyp b.Type | |
bobj.InterfaceMethod(btyp) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bmocks.go
generated bymockgen -destination bmocks.go b Interface
from this PR golang/mock#28