github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/test/fakes/roundtripper.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package fakes 3 4 import ( 5 "net/http" 6 "sync" 7 ) 8 9 type FakeRoundTripper struct { 10 RoundTripStub func(*http.Request) (*http.Response, error) 11 roundTripMutex sync.RWMutex 12 roundTripArgsForCall []struct { 13 arg1 *http.Request 14 } 15 roundTripReturns struct { 16 result1 *http.Response 17 result2 error 18 } 19 roundTripReturnsOnCall map[int]struct { 20 result1 *http.Response 21 result2 error 22 } 23 invocations map[string][][]interface{} 24 invocationsMutex sync.RWMutex 25 } 26 27 func (fake *FakeRoundTripper) RoundTrip(arg1 *http.Request) (*http.Response, error) { 28 fake.roundTripMutex.Lock() 29 ret, specificReturn := fake.roundTripReturnsOnCall[len(fake.roundTripArgsForCall)] 30 fake.roundTripArgsForCall = append(fake.roundTripArgsForCall, struct { 31 arg1 *http.Request 32 }{arg1}) 33 stub := fake.RoundTripStub 34 fakeReturns := fake.roundTripReturns 35 fake.recordInvocation("RoundTrip", []interface{}{arg1}) 36 fake.roundTripMutex.Unlock() 37 if stub != nil { 38 return stub(arg1) 39 } 40 if specificReturn { 41 return ret.result1, ret.result2 42 } 43 return fakeReturns.result1, fakeReturns.result2 44 } 45 46 func (fake *FakeRoundTripper) RoundTripCallCount() int { 47 fake.roundTripMutex.RLock() 48 defer fake.roundTripMutex.RUnlock() 49 return len(fake.roundTripArgsForCall) 50 } 51 52 func (fake *FakeRoundTripper) RoundTripCalls(stub func(*http.Request) (*http.Response, error)) { 53 fake.roundTripMutex.Lock() 54 defer fake.roundTripMutex.Unlock() 55 fake.RoundTripStub = stub 56 } 57 58 func (fake *FakeRoundTripper) RoundTripArgsForCall(i int) *http.Request { 59 fake.roundTripMutex.RLock() 60 defer fake.roundTripMutex.RUnlock() 61 argsForCall := fake.roundTripArgsForCall[i] 62 return argsForCall.arg1 63 } 64 65 func (fake *FakeRoundTripper) RoundTripReturns(result1 *http.Response, result2 error) { 66 fake.roundTripMutex.Lock() 67 defer fake.roundTripMutex.Unlock() 68 fake.RoundTripStub = nil 69 fake.roundTripReturns = struct { 70 result1 *http.Response 71 result2 error 72 }{result1, result2} 73 } 74 75 func (fake *FakeRoundTripper) RoundTripReturnsOnCall(i int, result1 *http.Response, result2 error) { 76 fake.roundTripMutex.Lock() 77 defer fake.roundTripMutex.Unlock() 78 fake.RoundTripStub = nil 79 if fake.roundTripReturnsOnCall == nil { 80 fake.roundTripReturnsOnCall = make(map[int]struct { 81 result1 *http.Response 82 result2 error 83 }) 84 } 85 fake.roundTripReturnsOnCall[i] = struct { 86 result1 *http.Response 87 result2 error 88 }{result1, result2} 89 } 90 91 func (fake *FakeRoundTripper) Invocations() map[string][][]interface{} { 92 fake.invocationsMutex.RLock() 93 defer fake.invocationsMutex.RUnlock() 94 fake.roundTripMutex.RLock() 95 defer fake.roundTripMutex.RUnlock() 96 copiedInvocations := map[string][][]interface{}{} 97 for key, value := range fake.invocations { 98 copiedInvocations[key] = value 99 } 100 return copiedInvocations 101 } 102 103 func (fake *FakeRoundTripper) recordInvocation(key string, args []interface{}) { 104 fake.invocationsMutex.Lock() 105 defer fake.invocationsMutex.Unlock() 106 if fake.invocations == nil { 107 fake.invocations = map[string][][]interface{}{} 108 } 109 if fake.invocations[key] == nil { 110 fake.invocations[key] = [][]interface{}{} 111 } 112 fake.invocations[key] = append(fake.invocations[key], args) 113 } 114 115 var _ http.RoundTripper = new(FakeRoundTripper)