github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/common/flogging/mock/write_syncer.go (about)

     1  // Code generated by counterfeiter. DO NOT EDIT.
     2  package mock
     3  
     4  import (
     5  	"sync"
     6  )
     7  
     8  type WriteSyncer struct {
     9  	SyncStub        func() error
    10  	syncMutex       sync.RWMutex
    11  	syncArgsForCall []struct {
    12  	}
    13  	syncReturns struct {
    14  		result1 error
    15  	}
    16  	syncReturnsOnCall map[int]struct {
    17  		result1 error
    18  	}
    19  	WriteStub        func([]byte) (int, error)
    20  	writeMutex       sync.RWMutex
    21  	writeArgsForCall []struct {
    22  		arg1 []byte
    23  	}
    24  	writeReturns struct {
    25  		result1 int
    26  		result2 error
    27  	}
    28  	writeReturnsOnCall map[int]struct {
    29  		result1 int
    30  		result2 error
    31  	}
    32  	invocations      map[string][][]interface{}
    33  	invocationsMutex sync.RWMutex
    34  }
    35  
    36  func (fake *WriteSyncer) Sync() error {
    37  	fake.syncMutex.Lock()
    38  	ret, specificReturn := fake.syncReturnsOnCall[len(fake.syncArgsForCall)]
    39  	fake.syncArgsForCall = append(fake.syncArgsForCall, struct {
    40  	}{})
    41  	fake.recordInvocation("Sync", []interface{}{})
    42  	fake.syncMutex.Unlock()
    43  	if fake.SyncStub != nil {
    44  		return fake.SyncStub()
    45  	}
    46  	if specificReturn {
    47  		return ret.result1
    48  	}
    49  	fakeReturns := fake.syncReturns
    50  	return fakeReturns.result1
    51  }
    52  
    53  func (fake *WriteSyncer) SyncCallCount() int {
    54  	fake.syncMutex.RLock()
    55  	defer fake.syncMutex.RUnlock()
    56  	return len(fake.syncArgsForCall)
    57  }
    58  
    59  func (fake *WriteSyncer) SyncCalls(stub func() error) {
    60  	fake.syncMutex.Lock()
    61  	defer fake.syncMutex.Unlock()
    62  	fake.SyncStub = stub
    63  }
    64  
    65  func (fake *WriteSyncer) SyncReturns(result1 error) {
    66  	fake.syncMutex.Lock()
    67  	defer fake.syncMutex.Unlock()
    68  	fake.SyncStub = nil
    69  	fake.syncReturns = struct {
    70  		result1 error
    71  	}{result1}
    72  }
    73  
    74  func (fake *WriteSyncer) SyncReturnsOnCall(i int, result1 error) {
    75  	fake.syncMutex.Lock()
    76  	defer fake.syncMutex.Unlock()
    77  	fake.SyncStub = nil
    78  	if fake.syncReturnsOnCall == nil {
    79  		fake.syncReturnsOnCall = make(map[int]struct {
    80  			result1 error
    81  		})
    82  	}
    83  	fake.syncReturnsOnCall[i] = struct {
    84  		result1 error
    85  	}{result1}
    86  }
    87  
    88  func (fake *WriteSyncer) Write(arg1 []byte) (int, error) {
    89  	var arg1Copy []byte
    90  	if arg1 != nil {
    91  		arg1Copy = make([]byte, len(arg1))
    92  		copy(arg1Copy, arg1)
    93  	}
    94  	fake.writeMutex.Lock()
    95  	ret, specificReturn := fake.writeReturnsOnCall[len(fake.writeArgsForCall)]
    96  	fake.writeArgsForCall = append(fake.writeArgsForCall, struct {
    97  		arg1 []byte
    98  	}{arg1Copy})
    99  	fake.recordInvocation("Write", []interface{}{arg1Copy})
   100  	fake.writeMutex.Unlock()
   101  	if fake.WriteStub != nil {
   102  		return fake.WriteStub(arg1)
   103  	}
   104  	if specificReturn {
   105  		return ret.result1, ret.result2
   106  	}
   107  	fakeReturns := fake.writeReturns
   108  	return fakeReturns.result1, fakeReturns.result2
   109  }
   110  
   111  func (fake *WriteSyncer) WriteCallCount() int {
   112  	fake.writeMutex.RLock()
   113  	defer fake.writeMutex.RUnlock()
   114  	return len(fake.writeArgsForCall)
   115  }
   116  
   117  func (fake *WriteSyncer) WriteCalls(stub func([]byte) (int, error)) {
   118  	fake.writeMutex.Lock()
   119  	defer fake.writeMutex.Unlock()
   120  	fake.WriteStub = stub
   121  }
   122  
   123  func (fake *WriteSyncer) WriteArgsForCall(i int) []byte {
   124  	fake.writeMutex.RLock()
   125  	defer fake.writeMutex.RUnlock()
   126  	argsForCall := fake.writeArgsForCall[i]
   127  	return argsForCall.arg1
   128  }
   129  
   130  func (fake *WriteSyncer) WriteReturns(result1 int, result2 error) {
   131  	fake.writeMutex.Lock()
   132  	defer fake.writeMutex.Unlock()
   133  	fake.WriteStub = nil
   134  	fake.writeReturns = struct {
   135  		result1 int
   136  		result2 error
   137  	}{result1, result2}
   138  }
   139  
   140  func (fake *WriteSyncer) WriteReturnsOnCall(i int, result1 int, result2 error) {
   141  	fake.writeMutex.Lock()
   142  	defer fake.writeMutex.Unlock()
   143  	fake.WriteStub = nil
   144  	if fake.writeReturnsOnCall == nil {
   145  		fake.writeReturnsOnCall = make(map[int]struct {
   146  			result1 int
   147  			result2 error
   148  		})
   149  	}
   150  	fake.writeReturnsOnCall[i] = struct {
   151  		result1 int
   152  		result2 error
   153  	}{result1, result2}
   154  }
   155  
   156  func (fake *WriteSyncer) Invocations() map[string][][]interface{} {
   157  	fake.invocationsMutex.RLock()
   158  	defer fake.invocationsMutex.RUnlock()
   159  	fake.syncMutex.RLock()
   160  	defer fake.syncMutex.RUnlock()
   161  	fake.writeMutex.RLock()
   162  	defer fake.writeMutex.RUnlock()
   163  	copiedInvocations := map[string][][]interface{}{}
   164  	for key, value := range fake.invocations {
   165  		copiedInvocations[key] = value
   166  	}
   167  	return copiedInvocations
   168  }
   169  
   170  func (fake *WriteSyncer) recordInvocation(key string, args []interface{}) {
   171  	fake.invocationsMutex.Lock()
   172  	defer fake.invocationsMutex.Unlock()
   173  	if fake.invocations == nil {
   174  		fake.invocations = map[string][][]interface{}{}
   175  	}
   176  	if fake.invocations[key] == nil {
   177  		fake.invocations[key] = [][]interface{}{}
   178  	}
   179  	fake.invocations[key] = append(fake.invocations[key], args)
   180  }