bugreport

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

README

The generated mock methods use some hardcoded variable/receiver names that can have conflicts with the argument names that are defined by the code for which the mock is generated when using the source generation method.

Example:

type Example interface {
	Method(_m, _mr, m, mr int)
}
// Method mocks base method
func (_m *MockExample) Method(_m int, _mr int, m int, mr int) {
	_m.ctrl.Call(_m, "Method", _m, _mr, m, mr)
}

In the above example one of the interface method parameters is called _m but unfortunately the generated receiver name is also called _m so the mock code won't compile.

The generator has to make sure that generated identifiers (e.g.: the receiver names) are always different from the arg names that might come from external sources.

Documentation

Overview

Package bugreport is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Example

type Example interface {
	// _m and _mr were used by the buggy code: the '_' prefix was there hoping
	// that no one will use method argument names starting with '_' reducing
	// the chance of collision with generated identifiers.
	// m and mr are used by the bugfixed new code, the '_' prefix has been
	// removed because the new code generator changes the names of the
	// generated identifiers in case they would collide with identifiers
	// coming from argument names.
	Method(_m, _mr, m, mr int)

	VarargMethod(_s, _x, a, ret int, varargs ...int)
}

type MockExample

type MockExample struct {
	// contains filtered or unexported fields
}

MockExample is a mock of Example interface

func NewMockExample

func NewMockExample(ctrl *gomock.Controller) *MockExample

NewMockExample creates a new mock instance

func (*MockExample) EXPECT

func (m *MockExample) EXPECT() *MockExampleMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockExample) Method

func (m_2 *MockExample) Method(_m, _mr, m, mr int)

Method mocks base method

func (*MockExample) VarargMethod

func (m *MockExample) VarargMethod(_s, _x, a, ret int, varargs ...int)

VarargMethod mocks base method

type MockExampleMockRecorder

type MockExampleMockRecorder struct {
	// contains filtered or unexported fields
}

MockExampleMockRecorder is the mock recorder for MockExample

func (*MockExampleMockRecorder) Method

func (mr_2 *MockExampleMockRecorder) Method(_m, _mr, m, mr interface{}) *gomock.Call

Method indicates an expected call of Method

func (*MockExampleMockRecorder) VarargMethod

func (mr *MockExampleMockRecorder) VarargMethod(_s, _x, a, ret interface{}, varargs ...interface{}) *gomock.Call

VarargMethod indicates an expected call of VarargMethod

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL