github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/applicationbits/applicationbitsfakes/fake_repository.go (about) 1 // This file was generated by counterfeiter 2 package applicationbitsfakes 3 4 import ( 5 "os" 6 "sync" 7 8 "code.cloudfoundry.org/cli/cf/api/applicationbits" 9 "code.cloudfoundry.org/cli/cf/api/resources" 10 ) 11 12 type FakeRepository struct { 13 GetApplicationFilesStub func(appFilesRequest []resources.AppFileResource) ([]resources.AppFileResource, error) 14 getApplicationFilesMutex sync.RWMutex 15 getApplicationFilesArgsForCall []struct { 16 appFilesRequest []resources.AppFileResource 17 } 18 getApplicationFilesReturns struct { 19 result1 []resources.AppFileResource 20 result2 error 21 } 22 UploadBitsStub func(appGUID string, zipFile *os.File, presentFiles []resources.AppFileResource) (apiErr error) 23 uploadBitsMutex sync.RWMutex 24 uploadBitsArgsForCall []struct { 25 appGUID string 26 zipFile *os.File 27 presentFiles []resources.AppFileResource 28 } 29 uploadBitsReturns struct { 30 result1 error 31 } 32 invocations map[string][][]interface{} 33 invocationsMutex sync.RWMutex 34 } 35 36 func (fake *FakeRepository) GetApplicationFiles(appFilesRequest []resources.AppFileResource) ([]resources.AppFileResource, error) { 37 var appFilesRequestCopy []resources.AppFileResource 38 if appFilesRequest != nil { 39 appFilesRequestCopy = make([]resources.AppFileResource, len(appFilesRequest)) 40 copy(appFilesRequestCopy, appFilesRequest) 41 } 42 fake.getApplicationFilesMutex.Lock() 43 fake.getApplicationFilesArgsForCall = append(fake.getApplicationFilesArgsForCall, struct { 44 appFilesRequest []resources.AppFileResource 45 }{appFilesRequestCopy}) 46 fake.recordInvocation("GetApplicationFiles", []interface{}{appFilesRequestCopy}) 47 fake.getApplicationFilesMutex.Unlock() 48 if fake.GetApplicationFilesStub != nil { 49 return fake.GetApplicationFilesStub(appFilesRequest) 50 } else { 51 return fake.getApplicationFilesReturns.result1, fake.getApplicationFilesReturns.result2 52 } 53 } 54 55 func (fake *FakeRepository) GetApplicationFilesCallCount() int { 56 fake.getApplicationFilesMutex.RLock() 57 defer fake.getApplicationFilesMutex.RUnlock() 58 return len(fake.getApplicationFilesArgsForCall) 59 } 60 61 func (fake *FakeRepository) GetApplicationFilesArgsForCall(i int) []resources.AppFileResource { 62 fake.getApplicationFilesMutex.RLock() 63 defer fake.getApplicationFilesMutex.RUnlock() 64 return fake.getApplicationFilesArgsForCall[i].appFilesRequest 65 } 66 67 func (fake *FakeRepository) GetApplicationFilesReturns(result1 []resources.AppFileResource, result2 error) { 68 fake.GetApplicationFilesStub = nil 69 fake.getApplicationFilesReturns = struct { 70 result1 []resources.AppFileResource 71 result2 error 72 }{result1, result2} 73 } 74 75 func (fake *FakeRepository) UploadBits(appGUID string, zipFile *os.File, presentFiles []resources.AppFileResource) (apiErr error) { 76 var presentFilesCopy []resources.AppFileResource 77 if presentFiles != nil { 78 presentFilesCopy = make([]resources.AppFileResource, len(presentFiles)) 79 copy(presentFilesCopy, presentFiles) 80 } 81 fake.uploadBitsMutex.Lock() 82 fake.uploadBitsArgsForCall = append(fake.uploadBitsArgsForCall, struct { 83 appGUID string 84 zipFile *os.File 85 presentFiles []resources.AppFileResource 86 }{appGUID, zipFile, presentFilesCopy}) 87 fake.recordInvocation("UploadBits", []interface{}{appGUID, zipFile, presentFilesCopy}) 88 fake.uploadBitsMutex.Unlock() 89 if fake.UploadBitsStub != nil { 90 return fake.UploadBitsStub(appGUID, zipFile, presentFiles) 91 } else { 92 return fake.uploadBitsReturns.result1 93 } 94 } 95 96 func (fake *FakeRepository) UploadBitsCallCount() int { 97 fake.uploadBitsMutex.RLock() 98 defer fake.uploadBitsMutex.RUnlock() 99 return len(fake.uploadBitsArgsForCall) 100 } 101 102 func (fake *FakeRepository) UploadBitsArgsForCall(i int) (string, *os.File, []resources.AppFileResource) { 103 fake.uploadBitsMutex.RLock() 104 defer fake.uploadBitsMutex.RUnlock() 105 return fake.uploadBitsArgsForCall[i].appGUID, fake.uploadBitsArgsForCall[i].zipFile, fake.uploadBitsArgsForCall[i].presentFiles 106 } 107 108 func (fake *FakeRepository) UploadBitsReturns(result1 error) { 109 fake.UploadBitsStub = nil 110 fake.uploadBitsReturns = struct { 111 result1 error 112 }{result1} 113 } 114 115 func (fake *FakeRepository) Invocations() map[string][][]interface{} { 116 fake.invocationsMutex.RLock() 117 defer fake.invocationsMutex.RUnlock() 118 fake.getApplicationFilesMutex.RLock() 119 defer fake.getApplicationFilesMutex.RUnlock() 120 fake.uploadBitsMutex.RLock() 121 defer fake.uploadBitsMutex.RUnlock() 122 return fake.invocations 123 } 124 125 func (fake *FakeRepository) recordInvocation(key string, args []interface{}) { 126 fake.invocationsMutex.Lock() 127 defer fake.invocationsMutex.Unlock() 128 if fake.invocations == nil { 129 fake.invocations = map[string][][]interface{}{} 130 } 131 if fake.invocations[key] == nil { 132 fake.invocations[key] = [][]interface{}{} 133 } 134 fake.invocations[key] = append(fake.invocations[key], args) 135 } 136 137 var _ applicationbits.Repository = new(FakeRepository)