github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/api/cloudcontroller/ccv2/ccv2fakes/fake_reader.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package ccv2fakes
     3  
     4  import (
     5  	"sync"
     6  
     7  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2"
     8  )
     9  
    10  type FakeReader struct {
    11  	ReadStub        func(p []byte) (n int, err error)
    12  	readMutex       sync.RWMutex
    13  	readArgsForCall []struct {
    14  		p []byte
    15  	}
    16  	readReturns struct {
    17  		result1 int
    18  		result2 error
    19  	}
    20  	readReturnsOnCall map[int]struct {
    21  		result1 int
    22  		result2 error
    23  	}
    24  	invocations      map[string][][]interface{}
    25  	invocationsMutex sync.RWMutex
    26  }
    27  
    28  func (fake *FakeReader) Read(p []byte) (n int, err error) {
    29  	var pCopy []byte
    30  	if p != nil {
    31  		pCopy = make([]byte, len(p))
    32  		copy(pCopy, p)
    33  	}
    34  	fake.readMutex.Lock()
    35  	ret, specificReturn := fake.readReturnsOnCall[len(fake.readArgsForCall)]
    36  	fake.readArgsForCall = append(fake.readArgsForCall, struct {
    37  		p []byte
    38  	}{pCopy})
    39  	fake.recordInvocation("Read", []interface{}{pCopy})
    40  	fake.readMutex.Unlock()
    41  	if fake.ReadStub != nil {
    42  		return fake.ReadStub(p)
    43  	}
    44  	if specificReturn {
    45  		return ret.result1, ret.result2
    46  	}
    47  	return fake.readReturns.result1, fake.readReturns.result2
    48  }
    49  
    50  func (fake *FakeReader) ReadCallCount() int {
    51  	fake.readMutex.RLock()
    52  	defer fake.readMutex.RUnlock()
    53  	return len(fake.readArgsForCall)
    54  }
    55  
    56  func (fake *FakeReader) ReadArgsForCall(i int) []byte {
    57  	fake.readMutex.RLock()
    58  	defer fake.readMutex.RUnlock()
    59  	return fake.readArgsForCall[i].p
    60  }
    61  
    62  func (fake *FakeReader) ReadReturns(result1 int, result2 error) {
    63  	fake.ReadStub = nil
    64  	fake.readReturns = struct {
    65  		result1 int
    66  		result2 error
    67  	}{result1, result2}
    68  }
    69  
    70  func (fake *FakeReader) ReadReturnsOnCall(i int, result1 int, result2 error) {
    71  	fake.ReadStub = nil
    72  	if fake.readReturnsOnCall == nil {
    73  		fake.readReturnsOnCall = make(map[int]struct {
    74  			result1 int
    75  			result2 error
    76  		})
    77  	}
    78  	fake.readReturnsOnCall[i] = struct {
    79  		result1 int
    80  		result2 error
    81  	}{result1, result2}
    82  }
    83  
    84  func (fake *FakeReader) Invocations() map[string][][]interface{} {
    85  	fake.invocationsMutex.RLock()
    86  	defer fake.invocationsMutex.RUnlock()
    87  	fake.readMutex.RLock()
    88  	defer fake.readMutex.RUnlock()
    89  	copiedInvocations := map[string][][]interface{}{}
    90  	for key, value := range fake.invocations {
    91  		copiedInvocations[key] = value
    92  	}
    93  	return copiedInvocations
    94  }
    95  
    96  func (fake *FakeReader) recordInvocation(key string, args []interface{}) {
    97  	fake.invocationsMutex.Lock()
    98  	defer fake.invocationsMutex.Unlock()
    99  	if fake.invocations == nil {
   100  		fake.invocations = map[string][][]interface{}{}
   101  	}
   102  	if fake.invocations[key] == nil {
   103  		fake.invocations[key] = [][]interface{}{}
   104  	}
   105  	fake.invocations[key] = append(fake.invocations[key], args)
   106  }
   107  
   108  var _ ccv2.Reader = new(FakeReader)