github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/util/download/downloadfakes/fake_httpclient.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package downloadfakes 3 4 import ( 5 "net/http" 6 "sync" 7 8 "code.cloudfoundry.org/cli/util/download" 9 ) 10 11 type FakeHTTPClient struct { 12 GetStub func(string) (*http.Response, error) 13 getMutex sync.RWMutex 14 getArgsForCall []struct { 15 arg1 string 16 } 17 getReturns struct { 18 result1 *http.Response 19 result2 error 20 } 21 getReturnsOnCall map[int]struct { 22 result1 *http.Response 23 result2 error 24 } 25 invocations map[string][][]interface{} 26 invocationsMutex sync.RWMutex 27 } 28 29 func (fake *FakeHTTPClient) Get(arg1 string) (*http.Response, error) { 30 fake.getMutex.Lock() 31 ret, specificReturn := fake.getReturnsOnCall[len(fake.getArgsForCall)] 32 fake.getArgsForCall = append(fake.getArgsForCall, struct { 33 arg1 string 34 }{arg1}) 35 fake.recordInvocation("Get", []interface{}{arg1}) 36 fake.getMutex.Unlock() 37 if fake.GetStub != nil { 38 return fake.GetStub(arg1) 39 } 40 if specificReturn { 41 return ret.result1, ret.result2 42 } 43 fakeReturns := fake.getReturns 44 return fakeReturns.result1, fakeReturns.result2 45 } 46 47 func (fake *FakeHTTPClient) GetCallCount() int { 48 fake.getMutex.RLock() 49 defer fake.getMutex.RUnlock() 50 return len(fake.getArgsForCall) 51 } 52 53 func (fake *FakeHTTPClient) GetCalls(stub func(string) (*http.Response, error)) { 54 fake.getMutex.Lock() 55 defer fake.getMutex.Unlock() 56 fake.GetStub = stub 57 } 58 59 func (fake *FakeHTTPClient) GetArgsForCall(i int) string { 60 fake.getMutex.RLock() 61 defer fake.getMutex.RUnlock() 62 argsForCall := fake.getArgsForCall[i] 63 return argsForCall.arg1 64 } 65 66 func (fake *FakeHTTPClient) GetReturns(result1 *http.Response, result2 error) { 67 fake.getMutex.Lock() 68 defer fake.getMutex.Unlock() 69 fake.GetStub = nil 70 fake.getReturns = struct { 71 result1 *http.Response 72 result2 error 73 }{result1, result2} 74 } 75 76 func (fake *FakeHTTPClient) GetReturnsOnCall(i int, result1 *http.Response, result2 error) { 77 fake.getMutex.Lock() 78 defer fake.getMutex.Unlock() 79 fake.GetStub = nil 80 if fake.getReturnsOnCall == nil { 81 fake.getReturnsOnCall = make(map[int]struct { 82 result1 *http.Response 83 result2 error 84 }) 85 } 86 fake.getReturnsOnCall[i] = struct { 87 result1 *http.Response 88 result2 error 89 }{result1, result2} 90 } 91 92 func (fake *FakeHTTPClient) Invocations() map[string][][]interface{} { 93 fake.invocationsMutex.RLock() 94 defer fake.invocationsMutex.RUnlock() 95 fake.getMutex.RLock() 96 defer fake.getMutex.RUnlock() 97 copiedInvocations := map[string][][]interface{}{} 98 for key, value := range fake.invocations { 99 copiedInvocations[key] = value 100 } 101 return copiedInvocations 102 } 103 104 func (fake *FakeHTTPClient) recordInvocation(key string, args []interface{}) { 105 fake.invocationsMutex.Lock() 106 defer fake.invocationsMutex.Unlock() 107 if fake.invocations == nil { 108 fake.invocations = map[string][][]interface{}{} 109 } 110 if fake.invocations[key] == nil { 111 fake.invocations[key] = [][]interface{}{} 112 } 113 fake.invocations[key] = append(fake.invocations[key], args) 114 } 115 116 var _ download.HTTPClient = new(FakeHTTPClient)