github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/db/dbfakes/fake_component_factory.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package dbfakes 3 4 import ( 5 "sync" 6 7 "github.com/pf-qiu/concourse/v6/atc" 8 "github.com/pf-qiu/concourse/v6/atc/db" 9 ) 10 11 type FakeComponentFactory struct { 12 CreateOrUpdateStub func(atc.Component) (db.Component, error) 13 createOrUpdateMutex sync.RWMutex 14 createOrUpdateArgsForCall []struct { 15 arg1 atc.Component 16 } 17 createOrUpdateReturns struct { 18 result1 db.Component 19 result2 error 20 } 21 createOrUpdateReturnsOnCall map[int]struct { 22 result1 db.Component 23 result2 error 24 } 25 FindStub func(string) (db.Component, bool, error) 26 findMutex sync.RWMutex 27 findArgsForCall []struct { 28 arg1 string 29 } 30 findReturns struct { 31 result1 db.Component 32 result2 bool 33 result3 error 34 } 35 findReturnsOnCall map[int]struct { 36 result1 db.Component 37 result2 bool 38 result3 error 39 } 40 invocations map[string][][]interface{} 41 invocationsMutex sync.RWMutex 42 } 43 44 func (fake *FakeComponentFactory) CreateOrUpdate(arg1 atc.Component) (db.Component, error) { 45 fake.createOrUpdateMutex.Lock() 46 ret, specificReturn := fake.createOrUpdateReturnsOnCall[len(fake.createOrUpdateArgsForCall)] 47 fake.createOrUpdateArgsForCall = append(fake.createOrUpdateArgsForCall, struct { 48 arg1 atc.Component 49 }{arg1}) 50 fake.recordInvocation("CreateOrUpdate", []interface{}{arg1}) 51 fake.createOrUpdateMutex.Unlock() 52 if fake.CreateOrUpdateStub != nil { 53 return fake.CreateOrUpdateStub(arg1) 54 } 55 if specificReturn { 56 return ret.result1, ret.result2 57 } 58 fakeReturns := fake.createOrUpdateReturns 59 return fakeReturns.result1, fakeReturns.result2 60 } 61 62 func (fake *FakeComponentFactory) CreateOrUpdateCallCount() int { 63 fake.createOrUpdateMutex.RLock() 64 defer fake.createOrUpdateMutex.RUnlock() 65 return len(fake.createOrUpdateArgsForCall) 66 } 67 68 func (fake *FakeComponentFactory) CreateOrUpdateCalls(stub func(atc.Component) (db.Component, error)) { 69 fake.createOrUpdateMutex.Lock() 70 defer fake.createOrUpdateMutex.Unlock() 71 fake.CreateOrUpdateStub = stub 72 } 73 74 func (fake *FakeComponentFactory) CreateOrUpdateArgsForCall(i int) atc.Component { 75 fake.createOrUpdateMutex.RLock() 76 defer fake.createOrUpdateMutex.RUnlock() 77 argsForCall := fake.createOrUpdateArgsForCall[i] 78 return argsForCall.arg1 79 } 80 81 func (fake *FakeComponentFactory) CreateOrUpdateReturns(result1 db.Component, result2 error) { 82 fake.createOrUpdateMutex.Lock() 83 defer fake.createOrUpdateMutex.Unlock() 84 fake.CreateOrUpdateStub = nil 85 fake.createOrUpdateReturns = struct { 86 result1 db.Component 87 result2 error 88 }{result1, result2} 89 } 90 91 func (fake *FakeComponentFactory) CreateOrUpdateReturnsOnCall(i int, result1 db.Component, result2 error) { 92 fake.createOrUpdateMutex.Lock() 93 defer fake.createOrUpdateMutex.Unlock() 94 fake.CreateOrUpdateStub = nil 95 if fake.createOrUpdateReturnsOnCall == nil { 96 fake.createOrUpdateReturnsOnCall = make(map[int]struct { 97 result1 db.Component 98 result2 error 99 }) 100 } 101 fake.createOrUpdateReturnsOnCall[i] = struct { 102 result1 db.Component 103 result2 error 104 }{result1, result2} 105 } 106 107 func (fake *FakeComponentFactory) Find(arg1 string) (db.Component, bool, error) { 108 fake.findMutex.Lock() 109 ret, specificReturn := fake.findReturnsOnCall[len(fake.findArgsForCall)] 110 fake.findArgsForCall = append(fake.findArgsForCall, struct { 111 arg1 string 112 }{arg1}) 113 fake.recordInvocation("Find", []interface{}{arg1}) 114 fake.findMutex.Unlock() 115 if fake.FindStub != nil { 116 return fake.FindStub(arg1) 117 } 118 if specificReturn { 119 return ret.result1, ret.result2, ret.result3 120 } 121 fakeReturns := fake.findReturns 122 return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 123 } 124 125 func (fake *FakeComponentFactory) FindCallCount() int { 126 fake.findMutex.RLock() 127 defer fake.findMutex.RUnlock() 128 return len(fake.findArgsForCall) 129 } 130 131 func (fake *FakeComponentFactory) FindCalls(stub func(string) (db.Component, bool, error)) { 132 fake.findMutex.Lock() 133 defer fake.findMutex.Unlock() 134 fake.FindStub = stub 135 } 136 137 func (fake *FakeComponentFactory) FindArgsForCall(i int) string { 138 fake.findMutex.RLock() 139 defer fake.findMutex.RUnlock() 140 argsForCall := fake.findArgsForCall[i] 141 return argsForCall.arg1 142 } 143 144 func (fake *FakeComponentFactory) FindReturns(result1 db.Component, result2 bool, result3 error) { 145 fake.findMutex.Lock() 146 defer fake.findMutex.Unlock() 147 fake.FindStub = nil 148 fake.findReturns = struct { 149 result1 db.Component 150 result2 bool 151 result3 error 152 }{result1, result2, result3} 153 } 154 155 func (fake *FakeComponentFactory) FindReturnsOnCall(i int, result1 db.Component, result2 bool, result3 error) { 156 fake.findMutex.Lock() 157 defer fake.findMutex.Unlock() 158 fake.FindStub = nil 159 if fake.findReturnsOnCall == nil { 160 fake.findReturnsOnCall = make(map[int]struct { 161 result1 db.Component 162 result2 bool 163 result3 error 164 }) 165 } 166 fake.findReturnsOnCall[i] = struct { 167 result1 db.Component 168 result2 bool 169 result3 error 170 }{result1, result2, result3} 171 } 172 173 func (fake *FakeComponentFactory) Invocations() map[string][][]interface{} { 174 fake.invocationsMutex.RLock() 175 defer fake.invocationsMutex.RUnlock() 176 fake.createOrUpdateMutex.RLock() 177 defer fake.createOrUpdateMutex.RUnlock() 178 fake.findMutex.RLock() 179 defer fake.findMutex.RUnlock() 180 copiedInvocations := map[string][][]interface{}{} 181 for key, value := range fake.invocations { 182 copiedInvocations[key] = value 183 } 184 return copiedInvocations 185 } 186 187 func (fake *FakeComponentFactory) recordInvocation(key string, args []interface{}) { 188 fake.invocationsMutex.Lock() 189 defer fake.invocationsMutex.Unlock() 190 if fake.invocations == nil { 191 fake.invocations = map[string][][]interface{}{} 192 } 193 if fake.invocations[key] == nil { 194 fake.invocations[key] = [][]interface{}{} 195 } 196 fake.invocations[key] = append(fake.invocations[key], args) 197 } 198 199 var _ db.ComponentFactory = new(FakeComponentFactory)