github.com/rancher/moq@v0.0.0-20200712062324-13d1f37d2d77/pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go (about) 1 // Code generated by moq; DO NOT EDIT. 2 // github.com/matryer/moq 3 4 package user 5 6 import ( 7 "github.com/matryer/somerepo" 8 "sync" 9 ) 10 11 var ( 12 lockServiceMockDoSomething sync.RWMutex 13 ) 14 15 // Ensure, that ServiceMock does implement Service. 16 // If this is not the case, regenerate this file with moq. 17 var _ Service = &ServiceMock{} 18 19 // ServiceMock is a mock implementation of Service. 20 // 21 // func TestSomethingThatUsesService(t *testing.T) { 22 // 23 // // make and configure a mocked Service 24 // mockedService := &ServiceMock{ 25 // DoSomethingFunc: func(in1 somerepo.SomeType) error { 26 // panic("mock out the DoSomething method") 27 // }, 28 // } 29 // 30 // // use mockedService in code that requires Service 31 // // and then make assertions. 32 // 33 // } 34 type ServiceMock struct { 35 // DoSomethingFunc mocks the DoSomething method. 36 DoSomethingFunc func(in1 somerepo.SomeType) error 37 38 // calls tracks calls to the methods. 39 calls struct { 40 // DoSomething holds details about calls to the DoSomething method. 41 DoSomething []struct { 42 // In1 is the in1 argument value. 43 In1 somerepo.SomeType 44 } 45 } 46 } 47 48 // DoSomething calls DoSomethingFunc. 49 func (mock *ServiceMock) DoSomething(in1 somerepo.SomeType) error { 50 if mock.DoSomethingFunc == nil { 51 panic("ServiceMock.DoSomethingFunc: method is nil but Service.DoSomething was just called") 52 } 53 callInfo := struct { 54 In1 somerepo.SomeType 55 }{ 56 In1: in1, 57 } 58 lockServiceMockDoSomething.Lock() 59 mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) 60 lockServiceMockDoSomething.Unlock() 61 return mock.DoSomethingFunc(in1) 62 } 63 64 // DoSomethingCalls gets all the calls that were made to DoSomething. 65 // Check the length with: 66 // len(mockedService.DoSomethingCalls()) 67 func (mock *ServiceMock) DoSomethingCalls() []struct { 68 In1 somerepo.SomeType 69 } { 70 var calls []struct { 71 In1 somerepo.SomeType 72 } 73 lockServiceMockDoSomething.RLock() 74 calls = mock.calls.DoSomething 75 lockServiceMockDoSomething.RUnlock() 76 return calls 77 }