2018-04-18 09:36:03 +02:00
|
|
|
// Code generated by moq; DO NOT EDIT.
|
|
|
|
// github.com/matryer/moq
|
|
|
|
|
|
|
|
package generate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
2018-06-04 14:22:28 +02:00
|
|
|
// Ensure, that MyInterfaceMock does implement MyInterface.
|
|
|
|
// If this is not the case, regenerate this file with moq.
|
|
|
|
var _ MyInterface = &MyInterfaceMock{}
|
|
|
|
|
2018-04-18 09:36:03 +02:00
|
|
|
// MyInterfaceMock is a mock implementation of MyInterface.
|
|
|
|
//
|
Internal registry for disambiguated imports, vars (#141)
* Internal registry for disambiguated imports, vars
- Move functionality in the moq package partially into
internal/{registry,template}.
- Leverage registry to assign unique package and variable/method
parameter names. Use import aliases if present in interface source
package.
BREAKING CHANGE: When the interface definition does not mention the
parameter names, the field names in call info anonymous struct will be
different.
The new field names are generated using the type info (string -> s,
int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
stringToInt etc.).
For example, for a string parameter previously if the field name was
'In1', the new field could be 'S' or 'S1' (depends on number of
string method parameters).
* Refactor golden file tests to be table-driven
* Fix sync pkg alias handling for moq generation
* Improve, add tests (increase coverage)
* Use $.Foo in template, avoid declaring variables
$ is set to the data argument passed to Execute, that is, to the
starting value of dot.
Variables were declared to be able to refer to the parent context.
* Consistent template field formatting
* Use tabs in generated Godoc comments' example code
* Minor simplification
* go generate
* Fix conflict for generated param name of pointer type
Excellent work by @sudo-suhas.
2021-02-01 20:20:20 +01:00
|
|
|
// func TestSomethingThatUsesMyInterface(t *testing.T) {
|
2018-04-18 09:36:03 +02:00
|
|
|
//
|
Internal registry for disambiguated imports, vars (#141)
* Internal registry for disambiguated imports, vars
- Move functionality in the moq package partially into
internal/{registry,template}.
- Leverage registry to assign unique package and variable/method
parameter names. Use import aliases if present in interface source
package.
BREAKING CHANGE: When the interface definition does not mention the
parameter names, the field names in call info anonymous struct will be
different.
The new field names are generated using the type info (string -> s,
int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
stringToInt etc.).
For example, for a string parameter previously if the field name was
'In1', the new field could be 'S' or 'S1' (depends on number of
string method parameters).
* Refactor golden file tests to be table-driven
* Fix sync pkg alias handling for moq generation
* Improve, add tests (increase coverage)
* Use $.Foo in template, avoid declaring variables
$ is set to the data argument passed to Execute, that is, to the
starting value of dot.
Variables were declared to be able to refer to the parent context.
* Consistent template field formatting
* Use tabs in generated Godoc comments' example code
* Minor simplification
* go generate
* Fix conflict for generated param name of pointer type
Excellent work by @sudo-suhas.
2021-02-01 20:20:20 +01:00
|
|
|
// // make and configure a mocked MyInterface
|
|
|
|
// mockedMyInterface := &MyInterfaceMock{
|
|
|
|
// OneFunc: func() bool {
|
|
|
|
// panic("mock out the One method")
|
|
|
|
// },
|
|
|
|
// ThreeFunc: func() string {
|
|
|
|
// panic("mock out the Three method")
|
|
|
|
// },
|
|
|
|
// TwoFunc: func() int {
|
|
|
|
// panic("mock out the Two method")
|
|
|
|
// },
|
|
|
|
// }
|
2018-04-18 09:36:03 +02:00
|
|
|
//
|
Internal registry for disambiguated imports, vars (#141)
* Internal registry for disambiguated imports, vars
- Move functionality in the moq package partially into
internal/{registry,template}.
- Leverage registry to assign unique package and variable/method
parameter names. Use import aliases if present in interface source
package.
BREAKING CHANGE: When the interface definition does not mention the
parameter names, the field names in call info anonymous struct will be
different.
The new field names are generated using the type info (string -> s,
int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
stringToInt etc.).
For example, for a string parameter previously if the field name was
'In1', the new field could be 'S' or 'S1' (depends on number of
string method parameters).
* Refactor golden file tests to be table-driven
* Fix sync pkg alias handling for moq generation
* Improve, add tests (increase coverage)
* Use $.Foo in template, avoid declaring variables
$ is set to the data argument passed to Execute, that is, to the
starting value of dot.
Variables were declared to be able to refer to the parent context.
* Consistent template field formatting
* Use tabs in generated Godoc comments' example code
* Minor simplification
* go generate
* Fix conflict for generated param name of pointer type
Excellent work by @sudo-suhas.
2021-02-01 20:20:20 +01:00
|
|
|
// // use mockedMyInterface in code that requires MyInterface
|
|
|
|
// // and then make assertions.
|
2018-04-18 09:36:03 +02:00
|
|
|
//
|
Internal registry for disambiguated imports, vars (#141)
* Internal registry for disambiguated imports, vars
- Move functionality in the moq package partially into
internal/{registry,template}.
- Leverage registry to assign unique package and variable/method
parameter names. Use import aliases if present in interface source
package.
BREAKING CHANGE: When the interface definition does not mention the
parameter names, the field names in call info anonymous struct will be
different.
The new field names are generated using the type info (string -> s,
int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
stringToInt etc.).
For example, for a string parameter previously if the field name was
'In1', the new field could be 'S' or 'S1' (depends on number of
string method parameters).
* Refactor golden file tests to be table-driven
* Fix sync pkg alias handling for moq generation
* Improve, add tests (increase coverage)
* Use $.Foo in template, avoid declaring variables
$ is set to the data argument passed to Execute, that is, to the
starting value of dot.
Variables were declared to be able to refer to the parent context.
* Consistent template field formatting
* Use tabs in generated Godoc comments' example code
* Minor simplification
* go generate
* Fix conflict for generated param name of pointer type
Excellent work by @sudo-suhas.
2021-02-01 20:20:20 +01:00
|
|
|
// }
|
2018-04-18 09:36:03 +02:00
|
|
|
type MyInterfaceMock struct {
|
|
|
|
// OneFunc mocks the One method.
|
|
|
|
OneFunc func() bool
|
|
|
|
|
|
|
|
// ThreeFunc mocks the Three method.
|
|
|
|
ThreeFunc func() string
|
|
|
|
|
|
|
|
// TwoFunc mocks the Two method.
|
|
|
|
TwoFunc func() int
|
|
|
|
|
|
|
|
// calls tracks calls to the methods.
|
|
|
|
calls struct {
|
|
|
|
// One holds details about calls to the One method.
|
|
|
|
One []struct {
|
|
|
|
}
|
|
|
|
// Three holds details about calls to the Three method.
|
|
|
|
Three []struct {
|
|
|
|
}
|
|
|
|
// Two holds details about calls to the Two method.
|
|
|
|
Two []struct {
|
|
|
|
}
|
|
|
|
}
|
2020-08-16 13:25:11 +02:00
|
|
|
lockOne sync.RWMutex
|
|
|
|
lockThree sync.RWMutex
|
|
|
|
lockTwo sync.RWMutex
|
2018-04-18 09:36:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// One calls OneFunc.
|
|
|
|
func (mock *MyInterfaceMock) One() bool {
|
|
|
|
if mock.OneFunc == nil {
|
2018-06-05 15:28:15 +02:00
|
|
|
panic("MyInterfaceMock.OneFunc: method is nil but MyInterface.One was just called")
|
2018-04-18 09:36:03 +02:00
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
}{}
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockOne.Lock()
|
2018-04-18 09:36:03 +02:00
|
|
|
mock.calls.One = append(mock.calls.One, callInfo)
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockOne.Unlock()
|
2018-04-18 09:36:03 +02:00
|
|
|
return mock.OneFunc()
|
|
|
|
}
|
|
|
|
|
|
|
|
// OneCalls gets all the calls that were made to One.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedMyInterface.OneCalls())
|
|
|
|
func (mock *MyInterfaceMock) OneCalls() []struct {
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
}
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockOne.RLock()
|
2018-04-18 09:36:03 +02:00
|
|
|
calls = mock.calls.One
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockOne.RUnlock()
|
2018-04-18 09:36:03 +02:00
|
|
|
return calls
|
|
|
|
}
|
|
|
|
|
|
|
|
// Three calls ThreeFunc.
|
|
|
|
func (mock *MyInterfaceMock) Three() string {
|
|
|
|
if mock.ThreeFunc == nil {
|
2018-06-05 15:28:15 +02:00
|
|
|
panic("MyInterfaceMock.ThreeFunc: method is nil but MyInterface.Three was just called")
|
2018-04-18 09:36:03 +02:00
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
}{}
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockThree.Lock()
|
2018-04-18 09:36:03 +02:00
|
|
|
mock.calls.Three = append(mock.calls.Three, callInfo)
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockThree.Unlock()
|
2018-04-18 09:36:03 +02:00
|
|
|
return mock.ThreeFunc()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ThreeCalls gets all the calls that were made to Three.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedMyInterface.ThreeCalls())
|
|
|
|
func (mock *MyInterfaceMock) ThreeCalls() []struct {
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
}
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockThree.RLock()
|
2018-04-18 09:36:03 +02:00
|
|
|
calls = mock.calls.Three
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockThree.RUnlock()
|
2018-04-18 09:36:03 +02:00
|
|
|
return calls
|
|
|
|
}
|
|
|
|
|
|
|
|
// Two calls TwoFunc.
|
|
|
|
func (mock *MyInterfaceMock) Two() int {
|
|
|
|
if mock.TwoFunc == nil {
|
2018-06-05 15:28:15 +02:00
|
|
|
panic("MyInterfaceMock.TwoFunc: method is nil but MyInterface.Two was just called")
|
2018-04-18 09:36:03 +02:00
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
}{}
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockTwo.Lock()
|
2018-04-18 09:36:03 +02:00
|
|
|
mock.calls.Two = append(mock.calls.Two, callInfo)
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockTwo.Unlock()
|
2018-04-18 09:36:03 +02:00
|
|
|
return mock.TwoFunc()
|
|
|
|
}
|
|
|
|
|
|
|
|
// TwoCalls gets all the calls that were made to Two.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedMyInterface.TwoCalls())
|
|
|
|
func (mock *MyInterfaceMock) TwoCalls() []struct {
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
}
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockTwo.RLock()
|
2018-04-18 09:36:03 +02:00
|
|
|
calls = mock.calls.Two
|
2020-08-16 13:25:11 +02:00
|
|
|
mock.lockTwo.RUnlock()
|
2018-04-18 09:36:03 +02:00
|
|
|
return calls
|
|
|
|
}
|