Merge pull request #58 from breml/update-go-generate
Update files generated by moq
This commit is contained in:
commit
f4ed779510
@ -62,7 +62,7 @@ type PersonStoreMock struct {
|
|||||||
// Create calls CreateFunc.
|
// Create calls CreateFunc.
|
||||||
func (mock *PersonStoreMock) Create(ctx context.Context, person *Person, confirm bool) error {
|
func (mock *PersonStoreMock) Create(ctx context.Context, person *Person, confirm bool) error {
|
||||||
if mock.CreateFunc == nil {
|
if mock.CreateFunc == nil {
|
||||||
panic("moq: PersonStoreMock.CreateFunc is nil but PersonStore.Create was just called")
|
panic("PersonStoreMock.CreateFunc: method is nil but PersonStore.Create was just called")
|
||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
@ -101,7 +101,7 @@ func (mock *PersonStoreMock) CreateCalls() []struct {
|
|||||||
// Get calls GetFunc.
|
// Get calls GetFunc.
|
||||||
func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error) {
|
func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error) {
|
||||||
if mock.GetFunc == nil {
|
if mock.GetFunc == nil {
|
||||||
panic("moq: PersonStoreMock.GetFunc is nil but PersonStore.Get was just called")
|
panic("PersonStoreMock.GetFunc: method is nil but PersonStore.Get was just called")
|
||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
Ctx context.Context
|
Ctx context.Context
|
||||||
|
@ -61,7 +61,7 @@ type MyInterfaceMock struct {
|
|||||||
// One calls OneFunc.
|
// One calls OneFunc.
|
||||||
func (mock *MyInterfaceMock) One() bool {
|
func (mock *MyInterfaceMock) One() bool {
|
||||||
if mock.OneFunc == nil {
|
if mock.OneFunc == nil {
|
||||||
panic("moq: MyInterfaceMock.OneFunc is nil but MyInterface.One was just called")
|
panic("MyInterfaceMock.OneFunc: method is nil but MyInterface.One was just called")
|
||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
}{}
|
}{}
|
||||||
@ -87,7 +87,7 @@ func (mock *MyInterfaceMock) OneCalls() []struct {
|
|||||||
// Three calls ThreeFunc.
|
// Three calls ThreeFunc.
|
||||||
func (mock *MyInterfaceMock) Three() string {
|
func (mock *MyInterfaceMock) Three() string {
|
||||||
if mock.ThreeFunc == nil {
|
if mock.ThreeFunc == nil {
|
||||||
panic("moq: MyInterfaceMock.ThreeFunc is nil but MyInterface.Three was just called")
|
panic("MyInterfaceMock.ThreeFunc: method is nil but MyInterface.Three was just called")
|
||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
}{}
|
}{}
|
||||||
@ -113,7 +113,7 @@ func (mock *MyInterfaceMock) ThreeCalls() []struct {
|
|||||||
// Two calls TwoFunc.
|
// Two calls TwoFunc.
|
||||||
func (mock *MyInterfaceMock) Two() int {
|
func (mock *MyInterfaceMock) Two() int {
|
||||||
if mock.TwoFunc == nil {
|
if mock.TwoFunc == nil {
|
||||||
panic("moq: MyInterfaceMock.TwoFunc is nil but MyInterface.Two was just called")
|
panic("MyInterfaceMock.TwoFunc: method is nil but MyInterface.Two was just called")
|
||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
}{}
|
}{}
|
||||||
|
@ -44,7 +44,7 @@ type ServiceMock struct {
|
|||||||
// User calls UserFunc.
|
// User calls UserFunc.
|
||||||
func (mock *ServiceMock) User(ID string) (dotimport.User, error) {
|
func (mock *ServiceMock) User(ID string) (dotimport.User, error) {
|
||||||
if mock.UserFunc == nil {
|
if mock.UserFunc == nil {
|
||||||
panic("moq: ServiceMock.UserFunc is nil but Service.User was just called")
|
panic("ServiceMock.UserFunc: method is nil but Service.User was just called")
|
||||||
}
|
}
|
||||||
callInfo := struct {
|
callInfo := struct {
|
||||||
ID string
|
ID string
|
||||||
|
@ -2,7 +2,7 @@ package user
|
|||||||
|
|
||||||
import "github.com/matryer/somerepo"
|
import "github.com/matryer/somerepo"
|
||||||
|
|
||||||
//go:generate moq . Service
|
//go:generate moq -out user_moq_test.go . Service
|
||||||
|
|
||||||
// Service does something good with computers.
|
// Service does something good with computers.
|
||||||
type Service interface {
|
type Service interface {
|
||||||
|
73
pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go
Normal file
73
pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Code generated by moq; DO NOT EDIT.
|
||||||
|
// github.com/matryer/moq
|
||||||
|
|
||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/matryer/somerepo"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
lockServiceMockDoSomething sync.RWMutex
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServiceMock is a mock implementation of Service.
|
||||||
|
//
|
||||||
|
// func TestSomethingThatUsesService(t *testing.T) {
|
||||||
|
//
|
||||||
|
// // make and configure a mocked Service
|
||||||
|
// mockedService := &ServiceMock{
|
||||||
|
// DoSomethingFunc: func(in1 somerepo.SomeType) error {
|
||||||
|
// panic("TODO: mock out the DoSomething method")
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // TODO: use mockedService in code that requires Service
|
||||||
|
// // and then make assertions.
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
type ServiceMock struct {
|
||||||
|
// DoSomethingFunc mocks the DoSomething method.
|
||||||
|
DoSomethingFunc func(in1 somerepo.SomeType) error
|
||||||
|
|
||||||
|
// calls tracks calls to the methods.
|
||||||
|
calls struct {
|
||||||
|
// DoSomething holds details about calls to the DoSomething method.
|
||||||
|
DoSomething []struct {
|
||||||
|
// In1 is the in1 argument value.
|
||||||
|
In1 somerepo.SomeType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DoSomething calls DoSomethingFunc.
|
||||||
|
func (mock *ServiceMock) DoSomething(in1 somerepo.SomeType) error {
|
||||||
|
if mock.DoSomethingFunc == nil {
|
||||||
|
panic("ServiceMock.DoSomethingFunc: method is nil but Service.DoSomething was just called")
|
||||||
|
}
|
||||||
|
callInfo := struct {
|
||||||
|
In1 somerepo.SomeType
|
||||||
|
}{
|
||||||
|
In1: in1,
|
||||||
|
}
|
||||||
|
lockServiceMockDoSomething.Lock()
|
||||||
|
mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo)
|
||||||
|
lockServiceMockDoSomething.Unlock()
|
||||||
|
return mock.DoSomethingFunc(in1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DoSomethingCalls gets all the calls that were made to DoSomething.
|
||||||
|
// Check the length with:
|
||||||
|
// len(mockedService.DoSomethingCalls())
|
||||||
|
func (mock *ServiceMock) DoSomethingCalls() []struct {
|
||||||
|
In1 somerepo.SomeType
|
||||||
|
} {
|
||||||
|
var calls []struct {
|
||||||
|
In1 somerepo.SomeType
|
||||||
|
}
|
||||||
|
lockServiceMockDoSomething.RLock()
|
||||||
|
calls = mock.calls.DoSomething
|
||||||
|
lockServiceMockDoSomething.RUnlock()
|
||||||
|
return calls
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user