Merge pull request #55 from breml/do-not-edit
Implement "DO NOT EDIT" comment convention
This commit is contained in:
commit
62f1b46be6
@ -1,8 +1,8 @@
|
|||||||
package example
|
// Code generated by moq; DO NOT EDIT.
|
||||||
|
|
||||||
// AUTOGENERATED BY MOQ - DO NOT EDIT
|
|
||||||
// github.com/matryer/moq
|
// github.com/matryer/moq
|
||||||
|
|
||||||
|
package example
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
@ -53,8 +53,8 @@ type PersonStoreMock struct {
|
|||||||
Get []struct {
|
Get []struct {
|
||||||
// Ctx is the ctx argument value.
|
// Ctx is the ctx argument value.
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
// Id is the id argument value.
|
// ID is the id argument value.
|
||||||
Id string
|
ID string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,10 +105,10 @@ func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error
|
|||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
Id string
|
ID string
|
||||||
}{
|
}{
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
Id: id,
|
ID: id,
|
||||||
}
|
}
|
||||||
lockPersonStoreMockGet.Lock()
|
lockPersonStoreMockGet.Lock()
|
||||||
mock.calls.Get = append(mock.calls.Get, callInfo)
|
mock.calls.Get = append(mock.calls.Get, callInfo)
|
||||||
@ -121,11 +121,11 @@ func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error
|
|||||||
// len(mockedPersonStore.GetCalls())
|
// len(mockedPersonStore.GetCalls())
|
||||||
func (mock *PersonStoreMock) GetCalls() []struct {
|
func (mock *PersonStoreMock) GetCalls() []struct {
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
Id string
|
ID string
|
||||||
} {
|
} {
|
||||||
var calls []struct {
|
var calls []struct {
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
Id string
|
ID string
|
||||||
}
|
}
|
||||||
lockPersonStoreMockGet.RLock()
|
lockPersonStoreMockGet.RLock()
|
||||||
calls = mock.calls.Get
|
calls = mock.calls.Get
|
||||||
|
137
generate/generated.go
Normal file
137
generate/generated.go
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
// Code generated by moq; DO NOT EDIT.
|
||||||
|
// github.com/matryer/moq
|
||||||
|
|
||||||
|
package generate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
lockMyInterfaceMockOne sync.RWMutex
|
||||||
|
lockMyInterfaceMockThree sync.RWMutex
|
||||||
|
lockMyInterfaceMockTwo sync.RWMutex
|
||||||
|
)
|
||||||
|
|
||||||
|
// MyInterfaceMock is a mock implementation of MyInterface.
|
||||||
|
//
|
||||||
|
// func TestSomethingThatUsesMyInterface(t *testing.T) {
|
||||||
|
//
|
||||||
|
// // make and configure a mocked MyInterface
|
||||||
|
// mockedMyInterface := &MyInterfaceMock{
|
||||||
|
// OneFunc: func() bool {
|
||||||
|
// panic("TODO: mock out the One method")
|
||||||
|
// },
|
||||||
|
// ThreeFunc: func() string {
|
||||||
|
// panic("TODO: mock out the Three method")
|
||||||
|
// },
|
||||||
|
// TwoFunc: func() int {
|
||||||
|
// panic("TODO: mock out the Two method")
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // TODO: use mockedMyInterface in code that requires MyInterface
|
||||||
|
// // and then make assertions.
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// One calls OneFunc.
|
||||||
|
func (mock *MyInterfaceMock) One() bool {
|
||||||
|
if mock.OneFunc == nil {
|
||||||
|
panic("moq: MyInterfaceMock.OneFunc is nil but MyInterface.One was just called")
|
||||||
|
}
|
||||||
|
callInfo := struct {
|
||||||
|
}{}
|
||||||
|
lockMyInterfaceMockOne.Lock()
|
||||||
|
mock.calls.One = append(mock.calls.One, callInfo)
|
||||||
|
lockMyInterfaceMockOne.Unlock()
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
lockMyInterfaceMockOne.RLock()
|
||||||
|
calls = mock.calls.One
|
||||||
|
lockMyInterfaceMockOne.RUnlock()
|
||||||
|
return calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// Three calls ThreeFunc.
|
||||||
|
func (mock *MyInterfaceMock) Three() string {
|
||||||
|
if mock.ThreeFunc == nil {
|
||||||
|
panic("moq: MyInterfaceMock.ThreeFunc is nil but MyInterface.Three was just called")
|
||||||
|
}
|
||||||
|
callInfo := struct {
|
||||||
|
}{}
|
||||||
|
lockMyInterfaceMockThree.Lock()
|
||||||
|
mock.calls.Three = append(mock.calls.Three, callInfo)
|
||||||
|
lockMyInterfaceMockThree.Unlock()
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
lockMyInterfaceMockThree.RLock()
|
||||||
|
calls = mock.calls.Three
|
||||||
|
lockMyInterfaceMockThree.RUnlock()
|
||||||
|
return calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// Two calls TwoFunc.
|
||||||
|
func (mock *MyInterfaceMock) Two() int {
|
||||||
|
if mock.TwoFunc == nil {
|
||||||
|
panic("moq: MyInterfaceMock.TwoFunc is nil but MyInterface.Two was just called")
|
||||||
|
}
|
||||||
|
callInfo := struct {
|
||||||
|
}{}
|
||||||
|
lockMyInterfaceMockTwo.Lock()
|
||||||
|
mock.calls.Two = append(mock.calls.Two, callInfo)
|
||||||
|
lockMyInterfaceMockTwo.Unlock()
|
||||||
|
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 {
|
||||||
|
}
|
||||||
|
lockMyInterfaceMockTwo.RLock()
|
||||||
|
calls = mock.calls.Two
|
||||||
|
lockMyInterfaceMockTwo.RUnlock()
|
||||||
|
return calls
|
||||||
|
}
|
@ -4,7 +4,7 @@ package moq
|
|||||||
var moqImports = []string{}
|
var moqImports = []string{}
|
||||||
|
|
||||||
// moqTemplate is the template for mocked code.
|
// moqTemplate is the template for mocked code.
|
||||||
var moqTemplate = `// Code generated by moq; DO NOT EDIT
|
var moqTemplate = `// Code generated by moq; DO NOT EDIT.
|
||||||
// github.com/matryer/moq
|
// github.com/matryer/moq
|
||||||
|
|
||||||
package {{.PackageName}}
|
package {{.PackageName}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by moq; DO NOT EDIT
|
// Code generated by moq; DO NOT EDIT.
|
||||||
// github.com/matryer/moq
|
// github.com/matryer/moq
|
||||||
|
|
||||||
package dotimport_test
|
package dotimport_test
|
||||||
|
Loading…
Reference in New Issue
Block a user