github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/apifakes/fake_curl_repository.go (about) 1 // This file was generated by counterfeiter 2 package apifakes 3 4 import ( 5 "sync" 6 7 "code.cloudfoundry.org/cli/cf/api" 8 ) 9 10 type FakeCurlRepository struct { 11 RequestStub func(method, path, header, body string) (resHeaders string, resBody string, apiErr error) 12 requestMutex sync.RWMutex 13 requestArgsForCall []struct { 14 method string 15 path string 16 header string 17 body string 18 } 19 requestReturns struct { 20 result1 string 21 result2 string 22 result3 error 23 } 24 invocations map[string][][]interface{} 25 invocationsMutex sync.RWMutex 26 } 27 28 func (fake *FakeCurlRepository) Request(method string, path string, header string, body string) (resHeaders string, resBody string, apiErr error) { 29 fake.requestMutex.Lock() 30 fake.requestArgsForCall = append(fake.requestArgsForCall, struct { 31 method string 32 path string 33 header string 34 body string 35 }{method, path, header, body}) 36 fake.recordInvocation("Request", []interface{}{method, path, header, body}) 37 fake.requestMutex.Unlock() 38 if fake.RequestStub != nil { 39 return fake.RequestStub(method, path, header, body) 40 } else { 41 return fake.requestReturns.result1, fake.requestReturns.result2, fake.requestReturns.result3 42 } 43 } 44 45 func (fake *FakeCurlRepository) RequestCallCount() int { 46 fake.requestMutex.RLock() 47 defer fake.requestMutex.RUnlock() 48 return len(fake.requestArgsForCall) 49 } 50 51 func (fake *FakeCurlRepository) RequestArgsForCall(i int) (string, string, string, string) { 52 fake.requestMutex.RLock() 53 defer fake.requestMutex.RUnlock() 54 return fake.requestArgsForCall[i].method, fake.requestArgsForCall[i].path, fake.requestArgsForCall[i].header, fake.requestArgsForCall[i].body 55 } 56 57 func (fake *FakeCurlRepository) RequestReturns(result1 string, result2 string, result3 error) { 58 fake.RequestStub = nil 59 fake.requestReturns = struct { 60 result1 string 61 result2 string 62 result3 error 63 }{result1, result2, result3} 64 } 65 66 func (fake *FakeCurlRepository) Invocations() map[string][][]interface{} { 67 fake.invocationsMutex.RLock() 68 defer fake.invocationsMutex.RUnlock() 69 fake.requestMutex.RLock() 70 defer fake.requestMutex.RUnlock() 71 return fake.invocations 72 } 73 74 func (fake *FakeCurlRepository) recordInvocation(key string, args []interface{}) { 75 fake.invocationsMutex.Lock() 76 defer fake.invocationsMutex.Unlock() 77 if fake.invocations == nil { 78 fake.invocations = map[string][][]interface{}{} 79 } 80 if fake.invocations[key] == nil { 81 fake.invocations[key] = [][]interface{}{} 82 } 83 fake.invocations[key] = append(fake.invocations[key], args) 84 } 85 86 var _ api.CurlRepository = new(FakeCurlRepository)