...

Source file src/sigs.k8s.io/release-utils/http/httpfakes/fake_agent_implementation.go

Documentation: sigs.k8s.io/release-utils/http/httpfakes

     1  /*
     2  Copyright The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Code generated by counterfeiter. DO NOT EDIT.
    18  package httpfakes
    19  
    20  import (
    21  	httpa "net/http"
    22  	"sync"
    23  
    24  	"sigs.k8s.io/release-utils/http"
    25  )
    26  
    27  type FakeAgentImplementation struct {
    28  	SendGetRequestStub        func(*httpa.Client, string) (*httpa.Response, error)
    29  	sendGetRequestMutex       sync.RWMutex
    30  	sendGetRequestArgsForCall []struct {
    31  		arg1 *httpa.Client
    32  		arg2 string
    33  	}
    34  	sendGetRequestReturns struct {
    35  		result1 *httpa.Response
    36  		result2 error
    37  	}
    38  	sendGetRequestReturnsOnCall map[int]struct {
    39  		result1 *httpa.Response
    40  		result2 error
    41  	}
    42  	SendPostRequestStub        func(*httpa.Client, string, []byte, string) (*httpa.Response, error)
    43  	sendPostRequestMutex       sync.RWMutex
    44  	sendPostRequestArgsForCall []struct {
    45  		arg1 *httpa.Client
    46  		arg2 string
    47  		arg3 []byte
    48  		arg4 string
    49  	}
    50  	sendPostRequestReturns struct {
    51  		result1 *httpa.Response
    52  		result2 error
    53  	}
    54  	sendPostRequestReturnsOnCall map[int]struct {
    55  		result1 *httpa.Response
    56  		result2 error
    57  	}
    58  	invocations      map[string][][]interface{}
    59  	invocationsMutex sync.RWMutex
    60  }
    61  
    62  func (fake *FakeAgentImplementation) SendGetRequest(arg1 *httpa.Client, arg2 string) (*httpa.Response, error) {
    63  	fake.sendGetRequestMutex.Lock()
    64  	ret, specificReturn := fake.sendGetRequestReturnsOnCall[len(fake.sendGetRequestArgsForCall)]
    65  	fake.sendGetRequestArgsForCall = append(fake.sendGetRequestArgsForCall, struct {
    66  		arg1 *httpa.Client
    67  		arg2 string
    68  	}{arg1, arg2})
    69  	stub := fake.SendGetRequestStub
    70  	fakeReturns := fake.sendGetRequestReturns
    71  	fake.recordInvocation("SendGetRequest", []interface{}{arg1, arg2})
    72  	fake.sendGetRequestMutex.Unlock()
    73  	if stub != nil {
    74  		return stub(arg1, arg2)
    75  	}
    76  	if specificReturn {
    77  		return ret.result1, ret.result2
    78  	}
    79  	return fakeReturns.result1, fakeReturns.result2
    80  }
    81  
    82  func (fake *FakeAgentImplementation) SendGetRequestCallCount() int {
    83  	fake.sendGetRequestMutex.RLock()
    84  	defer fake.sendGetRequestMutex.RUnlock()
    85  	return len(fake.sendGetRequestArgsForCall)
    86  }
    87  
    88  func (fake *FakeAgentImplementation) SendGetRequestCalls(stub func(*httpa.Client, string) (*httpa.Response, error)) {
    89  	fake.sendGetRequestMutex.Lock()
    90  	defer fake.sendGetRequestMutex.Unlock()
    91  	fake.SendGetRequestStub = stub
    92  }
    93  
    94  func (fake *FakeAgentImplementation) SendGetRequestArgsForCall(i int) (*httpa.Client, string) {
    95  	fake.sendGetRequestMutex.RLock()
    96  	defer fake.sendGetRequestMutex.RUnlock()
    97  	argsForCall := fake.sendGetRequestArgsForCall[i]
    98  	return argsForCall.arg1, argsForCall.arg2
    99  }
   100  
   101  func (fake *FakeAgentImplementation) SendGetRequestReturns(result1 *httpa.Response, result2 error) {
   102  	fake.sendGetRequestMutex.Lock()
   103  	defer fake.sendGetRequestMutex.Unlock()
   104  	fake.SendGetRequestStub = nil
   105  	fake.sendGetRequestReturns = struct {
   106  		result1 *httpa.Response
   107  		result2 error
   108  	}{result1, result2}
   109  }
   110  
   111  func (fake *FakeAgentImplementation) SendGetRequestReturnsOnCall(i int, result1 *httpa.Response, result2 error) {
   112  	fake.sendGetRequestMutex.Lock()
   113  	defer fake.sendGetRequestMutex.Unlock()
   114  	fake.SendGetRequestStub = nil
   115  	if fake.sendGetRequestReturnsOnCall == nil {
   116  		fake.sendGetRequestReturnsOnCall = make(map[int]struct {
   117  			result1 *httpa.Response
   118  			result2 error
   119  		})
   120  	}
   121  	fake.sendGetRequestReturnsOnCall[i] = struct {
   122  		result1 *httpa.Response
   123  		result2 error
   124  	}{result1, result2}
   125  }
   126  
   127  func (fake *FakeAgentImplementation) SendPostRequest(arg1 *httpa.Client, arg2 string, arg3 []byte, arg4 string) (*httpa.Response, error) {
   128  	var arg3Copy []byte
   129  	if arg3 != nil {
   130  		arg3Copy = make([]byte, len(arg3))
   131  		copy(arg3Copy, arg3)
   132  	}
   133  	fake.sendPostRequestMutex.Lock()
   134  	ret, specificReturn := fake.sendPostRequestReturnsOnCall[len(fake.sendPostRequestArgsForCall)]
   135  	fake.sendPostRequestArgsForCall = append(fake.sendPostRequestArgsForCall, struct {
   136  		arg1 *httpa.Client
   137  		arg2 string
   138  		arg3 []byte
   139  		arg4 string
   140  	}{arg1, arg2, arg3Copy, arg4})
   141  	stub := fake.SendPostRequestStub
   142  	fakeReturns := fake.sendPostRequestReturns
   143  	fake.recordInvocation("SendPostRequest", []interface{}{arg1, arg2, arg3Copy, arg4})
   144  	fake.sendPostRequestMutex.Unlock()
   145  	if stub != nil {
   146  		return stub(arg1, arg2, arg3, arg4)
   147  	}
   148  	if specificReturn {
   149  		return ret.result1, ret.result2
   150  	}
   151  	return fakeReturns.result1, fakeReturns.result2
   152  }
   153  
   154  func (fake *FakeAgentImplementation) SendPostRequestCallCount() int {
   155  	fake.sendPostRequestMutex.RLock()
   156  	defer fake.sendPostRequestMutex.RUnlock()
   157  	return len(fake.sendPostRequestArgsForCall)
   158  }
   159  
   160  func (fake *FakeAgentImplementation) SendPostRequestCalls(stub func(*httpa.Client, string, []byte, string) (*httpa.Response, error)) {
   161  	fake.sendPostRequestMutex.Lock()
   162  	defer fake.sendPostRequestMutex.Unlock()
   163  	fake.SendPostRequestStub = stub
   164  }
   165  
   166  func (fake *FakeAgentImplementation) SendPostRequestArgsForCall(i int) (*httpa.Client, string, []byte, string) {
   167  	fake.sendPostRequestMutex.RLock()
   168  	defer fake.sendPostRequestMutex.RUnlock()
   169  	argsForCall := fake.sendPostRequestArgsForCall[i]
   170  	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
   171  }
   172  
   173  func (fake *FakeAgentImplementation) SendPostRequestReturns(result1 *httpa.Response, result2 error) {
   174  	fake.sendPostRequestMutex.Lock()
   175  	defer fake.sendPostRequestMutex.Unlock()
   176  	fake.SendPostRequestStub = nil
   177  	fake.sendPostRequestReturns = struct {
   178  		result1 *httpa.Response
   179  		result2 error
   180  	}{result1, result2}
   181  }
   182  
   183  func (fake *FakeAgentImplementation) SendPostRequestReturnsOnCall(i int, result1 *httpa.Response, result2 error) {
   184  	fake.sendPostRequestMutex.Lock()
   185  	defer fake.sendPostRequestMutex.Unlock()
   186  	fake.SendPostRequestStub = nil
   187  	if fake.sendPostRequestReturnsOnCall == nil {
   188  		fake.sendPostRequestReturnsOnCall = make(map[int]struct {
   189  			result1 *httpa.Response
   190  			result2 error
   191  		})
   192  	}
   193  	fake.sendPostRequestReturnsOnCall[i] = struct {
   194  		result1 *httpa.Response
   195  		result2 error
   196  	}{result1, result2}
   197  }
   198  
   199  func (fake *FakeAgentImplementation) Invocations() map[string][][]interface{} {
   200  	fake.invocationsMutex.RLock()
   201  	defer fake.invocationsMutex.RUnlock()
   202  	fake.sendGetRequestMutex.RLock()
   203  	defer fake.sendGetRequestMutex.RUnlock()
   204  	fake.sendPostRequestMutex.RLock()
   205  	defer fake.sendPostRequestMutex.RUnlock()
   206  	copiedInvocations := map[string][][]interface{}{}
   207  	for key, value := range fake.invocations {
   208  		copiedInvocations[key] = value
   209  	}
   210  	return copiedInvocations
   211  }
   212  
   213  func (fake *FakeAgentImplementation) recordInvocation(key string, args []interface{}) {
   214  	fake.invocationsMutex.Lock()
   215  	defer fake.invocationsMutex.Unlock()
   216  	if fake.invocations == nil {
   217  		fake.invocations = map[string][][]interface{}{}
   218  	}
   219  	if fake.invocations[key] == nil {
   220  		fake.invocations[key] = [][]interface{}{}
   221  	}
   222  	fake.invocations[key] = append(fake.invocations[key], args)
   223  }
   224  
   225  var _ http.AgentImplementation = new(FakeAgentImplementation)
   226  

View as plain text