github.com/Capventis/moq@v0.2.6-0.20220316100624-05dd47497214/generate/generated.go (about) 1 // Code generated by moq; DO NOT EDIT. 2 // github.com/matryer/moq 3 4 package generate 5 6 import ( 7 "sync" 8 ) 9 10 // Ensure, that MyInterfaceMock does implement MyInterface. 11 // If this is not the case, regenerate this file with moq. 12 var _ MyInterface = &MyInterfaceMock{} 13 14 // MyInterfaceMock is a mock implementation of MyInterface. 15 // 16 // func TestSomethingThatUsesMyInterface(t *testing.T) { 17 // 18 // // make and configure a mocked MyInterface 19 // mockedMyInterface := &MyInterfaceMock{ 20 // OneFunc: func() bool { 21 // panic("mock out the One method") 22 // }, 23 // ThreeFunc: func() string { 24 // panic("mock out the Three method") 25 // }, 26 // TwoFunc: func() int { 27 // panic("mock out the Two method") 28 // }, 29 // } 30 // 31 // // use mockedMyInterface in code that requires MyInterface 32 // // and then make assertions. 33 // 34 // } 35 type MyInterfaceMock struct { 36 // OneFunc mocks the One method. 37 OneFunc func() bool 38 39 // ThreeFunc mocks the Three method. 40 ThreeFunc func() string 41 42 // TwoFunc mocks the Two method. 43 TwoFunc func() int 44 45 // calls tracks calls to the methods. 46 calls struct { 47 // One holds details about calls to the One method. 48 One []struct { 49 } 50 // Three holds details about calls to the Three method. 51 Three []struct { 52 } 53 // Two holds details about calls to the Two method. 54 Two []struct { 55 } 56 } 57 lockOne sync.RWMutex 58 lockThree sync.RWMutex 59 lockTwo sync.RWMutex 60 } 61 62 // One calls OneFunc. 63 func (mock *MyInterfaceMock) One() bool { 64 if mock.OneFunc == nil { 65 panic("MyInterfaceMock.OneFunc: method is nil but MyInterface.One was just called") 66 } 67 callInfo := struct { 68 }{} 69 mock.lockOne.Lock() 70 mock.calls.One = append(mock.calls.One, callInfo) 71 mock.lockOne.Unlock() 72 return mock.OneFunc() 73 } 74 75 // OneCalls gets all the calls that were made to One. 76 // Check the length with: 77 // len(mockedMyInterface.OneCalls()) 78 func (mock *MyInterfaceMock) OneCalls() []struct { 79 } { 80 var calls []struct { 81 } 82 mock.lockOne.RLock() 83 calls = mock.calls.One 84 mock.lockOne.RUnlock() 85 return calls 86 } 87 88 // Three calls ThreeFunc. 89 func (mock *MyInterfaceMock) Three() string { 90 if mock.ThreeFunc == nil { 91 panic("MyInterfaceMock.ThreeFunc: method is nil but MyInterface.Three was just called") 92 } 93 callInfo := struct { 94 }{} 95 mock.lockThree.Lock() 96 mock.calls.Three = append(mock.calls.Three, callInfo) 97 mock.lockThree.Unlock() 98 return mock.ThreeFunc() 99 } 100 101 // ThreeCalls gets all the calls that were made to Three. 102 // Check the length with: 103 // len(mockedMyInterface.ThreeCalls()) 104 func (mock *MyInterfaceMock) ThreeCalls() []struct { 105 } { 106 var calls []struct { 107 } 108 mock.lockThree.RLock() 109 calls = mock.calls.Three 110 mock.lockThree.RUnlock() 111 return calls 112 } 113 114 // Two calls TwoFunc. 115 func (mock *MyInterfaceMock) Two() int { 116 if mock.TwoFunc == nil { 117 panic("MyInterfaceMock.TwoFunc: method is nil but MyInterface.Two was just called") 118 } 119 callInfo := struct { 120 }{} 121 mock.lockTwo.Lock() 122 mock.calls.Two = append(mock.calls.Two, callInfo) 123 mock.lockTwo.Unlock() 124 return mock.TwoFunc() 125 } 126 127 // TwoCalls gets all the calls that were made to Two. 128 // Check the length with: 129 // len(mockedMyInterface.TwoCalls()) 130 func (mock *MyInterfaceMock) TwoCalls() []struct { 131 } { 132 var calls []struct { 133 } 134 mock.lockTwo.RLock() 135 calls = mock.calls.Two 136 mock.lockTwo.RUnlock() 137 return calls 138 }