github.com/rancher/moq@v0.0.0-20200712062324-13d1f37d2d77/pkg/moq/testpackages/imports/testdata/goimports.golden.go (about) 1 // Code generated by moq; DO NOT EDIT. 2 // github.com/matryer/moq 3 4 package two 5 6 import ( 7 "sync" 8 9 "github.com/matryer/moq/pkg/moq/testpackages/imports/one" 10 ) 11 12 var ( 13 lockDoSomethingMockAnother sync.RWMutex 14 lockDoSomethingMockDo sync.RWMutex 15 ) 16 17 // Ensure, that DoSomethingMock does implement DoSomething. 18 // If this is not the case, regenerate this file with moq. 19 var _ DoSomething = &DoSomethingMock{} 20 21 // DoSomethingMock is a mock implementation of DoSomething. 22 // 23 // func TestSomethingThatUsesDoSomething(t *testing.T) { 24 // 25 // // make and configure a mocked DoSomething 26 // mockedDoSomething := &DoSomethingMock{ 27 // AnotherFunc: func(thing one.Thing) error { 28 // panic("mock out the Another method") 29 // }, 30 // DoFunc: func(thing one.Thing) error { 31 // panic("mock out the Do method") 32 // }, 33 // } 34 // 35 // // use mockedDoSomething in code that requires DoSomething 36 // // and then make assertions. 37 // 38 // } 39 type DoSomethingMock struct { 40 // AnotherFunc mocks the Another method. 41 AnotherFunc func(thing one.Thing) error 42 43 // DoFunc mocks the Do method. 44 DoFunc func(thing one.Thing) error 45 46 // calls tracks calls to the methods. 47 calls struct { 48 // Another holds details about calls to the Another method. 49 Another []struct { 50 // Thing is the thing argument value. 51 Thing one.Thing 52 } 53 // Do holds details about calls to the Do method. 54 Do []struct { 55 // Thing is the thing argument value. 56 Thing one.Thing 57 } 58 } 59 } 60 61 // Another calls AnotherFunc. 62 func (mock *DoSomethingMock) Another(thing one.Thing) error { 63 if mock.AnotherFunc == nil { 64 panic("DoSomethingMock.AnotherFunc: method is nil but DoSomething.Another was just called") 65 } 66 callInfo := struct { 67 Thing one.Thing 68 }{ 69 Thing: thing, 70 } 71 lockDoSomethingMockAnother.Lock() 72 mock.calls.Another = append(mock.calls.Another, callInfo) 73 lockDoSomethingMockAnother.Unlock() 74 return mock.AnotherFunc(thing) 75 } 76 77 // AnotherCalls gets all the calls that were made to Another. 78 // Check the length with: 79 // len(mockedDoSomething.AnotherCalls()) 80 func (mock *DoSomethingMock) AnotherCalls() []struct { 81 Thing one.Thing 82 } { 83 var calls []struct { 84 Thing one.Thing 85 } 86 lockDoSomethingMockAnother.RLock() 87 calls = mock.calls.Another 88 lockDoSomethingMockAnother.RUnlock() 89 return calls 90 } 91 92 // Do calls DoFunc. 93 func (mock *DoSomethingMock) Do(thing one.Thing) error { 94 if mock.DoFunc == nil { 95 panic("DoSomethingMock.DoFunc: method is nil but DoSomething.Do was just called") 96 } 97 callInfo := struct { 98 Thing one.Thing 99 }{ 100 Thing: thing, 101 } 102 lockDoSomethingMockDo.Lock() 103 mock.calls.Do = append(mock.calls.Do, callInfo) 104 lockDoSomethingMockDo.Unlock() 105 return mock.DoFunc(thing) 106 } 107 108 // DoCalls gets all the calls that were made to Do. 109 // Check the length with: 110 // len(mockedDoSomething.DoCalls()) 111 func (mock *DoSomethingMock) DoCalls() []struct { 112 Thing one.Thing 113 } { 114 var calls []struct { 115 Thing one.Thing 116 } 117 lockDoSomethingMockDo.RLock() 118 calls = mock.calls.Do 119 lockDoSomethingMockDo.RUnlock() 120 return calls 121 }