github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/scheduler/schedulerfakes/fake_algorithm.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package schedulerfakes 3 4 import ( 5 "context" 6 "sync" 7 8 "github.com/pf-qiu/concourse/v6/atc/db" 9 "github.com/pf-qiu/concourse/v6/atc/scheduler" 10 ) 11 12 type FakeAlgorithm struct { 13 ComputeStub func(context.Context, db.Job, db.InputConfigs) (db.InputMapping, bool, bool, error) 14 computeMutex sync.RWMutex 15 computeArgsForCall []struct { 16 arg1 context.Context 17 arg2 db.Job 18 arg3 db.InputConfigs 19 } 20 computeReturns struct { 21 result1 db.InputMapping 22 result2 bool 23 result3 bool 24 result4 error 25 } 26 computeReturnsOnCall map[int]struct { 27 result1 db.InputMapping 28 result2 bool 29 result3 bool 30 result4 error 31 } 32 invocations map[string][][]interface{} 33 invocationsMutex sync.RWMutex 34 } 35 36 func (fake *FakeAlgorithm) Compute(arg1 context.Context, arg2 db.Job, arg3 db.InputConfigs) (db.InputMapping, bool, bool, error) { 37 fake.computeMutex.Lock() 38 ret, specificReturn := fake.computeReturnsOnCall[len(fake.computeArgsForCall)] 39 fake.computeArgsForCall = append(fake.computeArgsForCall, struct { 40 arg1 context.Context 41 arg2 db.Job 42 arg3 db.InputConfigs 43 }{arg1, arg2, arg3}) 44 fake.recordInvocation("Compute", []interface{}{arg1, arg2, arg3}) 45 fake.computeMutex.Unlock() 46 if fake.ComputeStub != nil { 47 return fake.ComputeStub(arg1, arg2, arg3) 48 } 49 if specificReturn { 50 return ret.result1, ret.result2, ret.result3, ret.result4 51 } 52 fakeReturns := fake.computeReturns 53 return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3, fakeReturns.result4 54 } 55 56 func (fake *FakeAlgorithm) ComputeCallCount() int { 57 fake.computeMutex.RLock() 58 defer fake.computeMutex.RUnlock() 59 return len(fake.computeArgsForCall) 60 } 61 62 func (fake *FakeAlgorithm) ComputeCalls(stub func(context.Context, db.Job, db.InputConfigs) (db.InputMapping, bool, bool, error)) { 63 fake.computeMutex.Lock() 64 defer fake.computeMutex.Unlock() 65 fake.ComputeStub = stub 66 } 67 68 func (fake *FakeAlgorithm) ComputeArgsForCall(i int) (context.Context, db.Job, db.InputConfigs) { 69 fake.computeMutex.RLock() 70 defer fake.computeMutex.RUnlock() 71 argsForCall := fake.computeArgsForCall[i] 72 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 73 } 74 75 func (fake *FakeAlgorithm) ComputeReturns(result1 db.InputMapping, result2 bool, result3 bool, result4 error) { 76 fake.computeMutex.Lock() 77 defer fake.computeMutex.Unlock() 78 fake.ComputeStub = nil 79 fake.computeReturns = struct { 80 result1 db.InputMapping 81 result2 bool 82 result3 bool 83 result4 error 84 }{result1, result2, result3, result4} 85 } 86 87 func (fake *FakeAlgorithm) ComputeReturnsOnCall(i int, result1 db.InputMapping, result2 bool, result3 bool, result4 error) { 88 fake.computeMutex.Lock() 89 defer fake.computeMutex.Unlock() 90 fake.ComputeStub = nil 91 if fake.computeReturnsOnCall == nil { 92 fake.computeReturnsOnCall = make(map[int]struct { 93 result1 db.InputMapping 94 result2 bool 95 result3 bool 96 result4 error 97 }) 98 } 99 fake.computeReturnsOnCall[i] = struct { 100 result1 db.InputMapping 101 result2 bool 102 result3 bool 103 result4 error 104 }{result1, result2, result3, result4} 105 } 106 107 func (fake *FakeAlgorithm) Invocations() map[string][][]interface{} { 108 fake.invocationsMutex.RLock() 109 defer fake.invocationsMutex.RUnlock() 110 fake.computeMutex.RLock() 111 defer fake.computeMutex.RUnlock() 112 copiedInvocations := map[string][][]interface{}{} 113 for key, value := range fake.invocations { 114 copiedInvocations[key] = value 115 } 116 return copiedInvocations 117 } 118 119 func (fake *FakeAlgorithm) recordInvocation(key string, args []interface{}) { 120 fake.invocationsMutex.Lock() 121 defer fake.invocationsMutex.Unlock() 122 if fake.invocations == nil { 123 fake.invocations = map[string][][]interface{}{} 124 } 125 if fake.invocations[key] == nil { 126 fake.invocations[key] = [][]interface{}{} 127 } 128 fake.invocations[key] = append(fake.invocations[key], args) 129 } 130 131 var _ scheduler.Algorithm = new(FakeAlgorithm)