github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/appinstances/appinstancesfakes/fake_repository.go (about) 1 // This file was generated by counterfeiter 2 package appinstancesfakes 3 4 import ( 5 "sync" 6 7 "code.cloudfoundry.org/cli/cf/api/appinstances" 8 "code.cloudfoundry.org/cli/cf/models" 9 ) 10 11 type FakeRepository struct { 12 GetInstancesStub func(appGUID string) (instances []models.AppInstanceFields, apiErr error) 13 getInstancesMutex sync.RWMutex 14 getInstancesArgsForCall []struct { 15 appGUID string 16 } 17 getInstancesReturns struct { 18 result1 []models.AppInstanceFields 19 result2 error 20 } 21 DeleteInstanceStub func(appGUID string, instance int) error 22 deleteInstanceMutex sync.RWMutex 23 deleteInstanceArgsForCall []struct { 24 appGUID string 25 instance int 26 } 27 deleteInstanceReturns struct { 28 result1 error 29 } 30 invocations map[string][][]interface{} 31 invocationsMutex sync.RWMutex 32 } 33 34 func (fake *FakeRepository) GetInstances(appGUID string) (instances []models.AppInstanceFields, apiErr error) { 35 fake.getInstancesMutex.Lock() 36 fake.getInstancesArgsForCall = append(fake.getInstancesArgsForCall, struct { 37 appGUID string 38 }{appGUID}) 39 fake.recordInvocation("GetInstances", []interface{}{appGUID}) 40 fake.getInstancesMutex.Unlock() 41 if fake.GetInstancesStub != nil { 42 return fake.GetInstancesStub(appGUID) 43 } else { 44 return fake.getInstancesReturns.result1, fake.getInstancesReturns.result2 45 } 46 } 47 48 func (fake *FakeRepository) GetInstancesCallCount() int { 49 fake.getInstancesMutex.RLock() 50 defer fake.getInstancesMutex.RUnlock() 51 return len(fake.getInstancesArgsForCall) 52 } 53 54 func (fake *FakeRepository) GetInstancesArgsForCall(i int) string { 55 fake.getInstancesMutex.RLock() 56 defer fake.getInstancesMutex.RUnlock() 57 return fake.getInstancesArgsForCall[i].appGUID 58 } 59 60 func (fake *FakeRepository) GetInstancesReturns(result1 []models.AppInstanceFields, result2 error) { 61 fake.GetInstancesStub = nil 62 fake.getInstancesReturns = struct { 63 result1 []models.AppInstanceFields 64 result2 error 65 }{result1, result2} 66 } 67 68 func (fake *FakeRepository) DeleteInstance(appGUID string, instance int) error { 69 fake.deleteInstanceMutex.Lock() 70 fake.deleteInstanceArgsForCall = append(fake.deleteInstanceArgsForCall, struct { 71 appGUID string 72 instance int 73 }{appGUID, instance}) 74 fake.recordInvocation("DeleteInstance", []interface{}{appGUID, instance}) 75 fake.deleteInstanceMutex.Unlock() 76 if fake.DeleteInstanceStub != nil { 77 return fake.DeleteInstanceStub(appGUID, instance) 78 } else { 79 return fake.deleteInstanceReturns.result1 80 } 81 } 82 83 func (fake *FakeRepository) DeleteInstanceCallCount() int { 84 fake.deleteInstanceMutex.RLock() 85 defer fake.deleteInstanceMutex.RUnlock() 86 return len(fake.deleteInstanceArgsForCall) 87 } 88 89 func (fake *FakeRepository) DeleteInstanceArgsForCall(i int) (string, int) { 90 fake.deleteInstanceMutex.RLock() 91 defer fake.deleteInstanceMutex.RUnlock() 92 return fake.deleteInstanceArgsForCall[i].appGUID, fake.deleteInstanceArgsForCall[i].instance 93 } 94 95 func (fake *FakeRepository) DeleteInstanceReturns(result1 error) { 96 fake.DeleteInstanceStub = nil 97 fake.deleteInstanceReturns = struct { 98 result1 error 99 }{result1} 100 } 101 102 func (fake *FakeRepository) Invocations() map[string][][]interface{} { 103 fake.invocationsMutex.RLock() 104 defer fake.invocationsMutex.RUnlock() 105 fake.getInstancesMutex.RLock() 106 defer fake.getInstancesMutex.RUnlock() 107 fake.deleteInstanceMutex.RLock() 108 defer fake.deleteInstanceMutex.RUnlock() 109 return fake.invocations 110 } 111 112 func (fake *FakeRepository) recordInvocation(key string, args []interface{}) { 113 fake.invocationsMutex.Lock() 114 defer fake.invocationsMutex.Unlock() 115 if fake.invocations == nil { 116 fake.invocations = map[string][][]interface{}{} 117 } 118 if fake.invocations[key] == nil { 119 fake.invocations[key] = [][]interface{}{} 120 } 121 fake.invocations[key] = append(fake.invocations[key], args) 122 } 123 124 var _ appinstances.Repository = new(FakeRepository)