github.com/Hnampk/fabric@v2.1.1+incompatible/gossip/privdata/mocks/sleeper.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package mocks 3 4 import ( 5 "sync" 6 "time" 7 ) 8 9 type Sleeper struct { 10 SleepStub func(time.Duration) 11 sleepMutex sync.RWMutex 12 sleepArgsForCall []struct { 13 arg1 time.Duration 14 } 15 invocations map[string][][]interface{} 16 invocationsMutex sync.RWMutex 17 } 18 19 func (fake *Sleeper) Sleep(arg1 time.Duration) { 20 fake.sleepMutex.Lock() 21 fake.sleepArgsForCall = append(fake.sleepArgsForCall, struct { 22 arg1 time.Duration 23 }{arg1}) 24 fake.recordInvocation("Sleep", []interface{}{arg1}) 25 fake.sleepMutex.Unlock() 26 if fake.SleepStub != nil { 27 fake.SleepStub(arg1) 28 } 29 } 30 31 func (fake *Sleeper) SleepCallCount() int { 32 fake.sleepMutex.RLock() 33 defer fake.sleepMutex.RUnlock() 34 return len(fake.sleepArgsForCall) 35 } 36 37 func (fake *Sleeper) SleepArgsForCall(i int) time.Duration { 38 fake.sleepMutex.RLock() 39 defer fake.sleepMutex.RUnlock() 40 return fake.sleepArgsForCall[i].arg1 41 } 42 43 func (fake *Sleeper) Invocations() map[string][][]interface{} { 44 fake.invocationsMutex.RLock() 45 defer fake.invocationsMutex.RUnlock() 46 fake.sleepMutex.RLock() 47 defer fake.sleepMutex.RUnlock() 48 copiedInvocations := map[string][][]interface{}{} 49 for key, value := range fake.invocations { 50 copiedInvocations[key] = value 51 } 52 return copiedInvocations 53 } 54 55 func (fake *Sleeper) recordInvocation(key string, args []interface{}) { 56 fake.invocationsMutex.Lock() 57 defer fake.invocationsMutex.Unlock() 58 if fake.invocations == nil { 59 fake.invocations = map[string][][]interface{}{} 60 } 61 if fake.invocations[key] == nil { 62 fake.invocations[key] = [][]interface{}{} 63 } 64 fake.invocations[key] = append(fake.invocations[key], args) 65 }