github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/actors/actorsfakes/fake_push_actor.go (about)

     1  // This file was generated by counterfeiter
     2  package actorsfakes
     3  
     4  import (
     5  	"os"
     6  	"sync"
     7  
     8  	"code.cloudfoundry.org/cli/cf/actors"
     9  	"code.cloudfoundry.org/cli/cf/api/resources"
    10  	"code.cloudfoundry.org/cli/cf/models"
    11  )
    12  
    13  type FakePushActor struct {
    14  	UploadAppStub        func(appGUID string, zipFile *os.File, presentFiles []resources.AppFileResource) error
    15  	uploadAppMutex       sync.RWMutex
    16  	uploadAppArgsForCall []struct {
    17  		appGUID      string
    18  		zipFile      *os.File
    19  		presentFiles []resources.AppFileResource
    20  	}
    21  	uploadAppReturns struct {
    22  		result1 error
    23  	}
    24  	ProcessPathStub        func(dirOrZipFile string, f func(string) error) error
    25  	processPathMutex       sync.RWMutex
    26  	processPathArgsForCall []struct {
    27  		dirOrZipFile string
    28  		f            func(string) error
    29  	}
    30  	processPathReturns struct {
    31  		result1 error
    32  	}
    33  	GatherFilesStub        func(localFiles []models.AppFileFields, appDir string, uploadDir string, useCache bool) ([]resources.AppFileResource, bool, error)
    34  	gatherFilesMutex       sync.RWMutex
    35  	gatherFilesArgsForCall []struct {
    36  		localFiles []models.AppFileFields
    37  		appDir     string
    38  		uploadDir  string
    39  		useCache   bool
    40  	}
    41  	gatherFilesReturns struct {
    42  		result1 []resources.AppFileResource
    43  		result2 bool
    44  		result3 error
    45  	}
    46  	ValidateAppParamsStub        func(apps []models.AppParams) []error
    47  	validateAppParamsMutex       sync.RWMutex
    48  	validateAppParamsArgsForCall []struct {
    49  		apps []models.AppParams
    50  	}
    51  	validateAppParamsReturns struct {
    52  		result1 []error
    53  	}
    54  	MapManifestRouteStub        func(routeName string, app models.Application, appParamsFromContext models.AppParams) error
    55  	mapManifestRouteMutex       sync.RWMutex
    56  	mapManifestRouteArgsForCall []struct {
    57  		routeName            string
    58  		app                  models.Application
    59  		appParamsFromContext models.AppParams
    60  	}
    61  	mapManifestRouteReturns struct {
    62  		result1 error
    63  	}
    64  	invocations      map[string][][]interface{}
    65  	invocationsMutex sync.RWMutex
    66  }
    67  
    68  func (fake *FakePushActor) UploadApp(appGUID string, zipFile *os.File, presentFiles []resources.AppFileResource) error {
    69  	var presentFilesCopy []resources.AppFileResource
    70  	if presentFiles != nil {
    71  		presentFilesCopy = make([]resources.AppFileResource, len(presentFiles))
    72  		copy(presentFilesCopy, presentFiles)
    73  	}
    74  	fake.uploadAppMutex.Lock()
    75  	fake.uploadAppArgsForCall = append(fake.uploadAppArgsForCall, struct {
    76  		appGUID      string
    77  		zipFile      *os.File
    78  		presentFiles []resources.AppFileResource
    79  	}{appGUID, zipFile, presentFilesCopy})
    80  	fake.recordInvocation("UploadApp", []interface{}{appGUID, zipFile, presentFilesCopy})
    81  	fake.uploadAppMutex.Unlock()
    82  	if fake.UploadAppStub != nil {
    83  		return fake.UploadAppStub(appGUID, zipFile, presentFiles)
    84  	} else {
    85  		return fake.uploadAppReturns.result1
    86  	}
    87  }
    88  
    89  func (fake *FakePushActor) UploadAppCallCount() int {
    90  	fake.uploadAppMutex.RLock()
    91  	defer fake.uploadAppMutex.RUnlock()
    92  	return len(fake.uploadAppArgsForCall)
    93  }
    94  
    95  func (fake *FakePushActor) UploadAppArgsForCall(i int) (string, *os.File, []resources.AppFileResource) {
    96  	fake.uploadAppMutex.RLock()
    97  	defer fake.uploadAppMutex.RUnlock()
    98  	return fake.uploadAppArgsForCall[i].appGUID, fake.uploadAppArgsForCall[i].zipFile, fake.uploadAppArgsForCall[i].presentFiles
    99  }
   100  
   101  func (fake *FakePushActor) UploadAppReturns(result1 error) {
   102  	fake.UploadAppStub = nil
   103  	fake.uploadAppReturns = struct {
   104  		result1 error
   105  	}{result1}
   106  }
   107  
   108  func (fake *FakePushActor) ProcessPath(dirOrZipFile string, f func(string) error) error {
   109  	fake.processPathMutex.Lock()
   110  	fake.processPathArgsForCall = append(fake.processPathArgsForCall, struct {
   111  		dirOrZipFile string
   112  		f            func(string) error
   113  	}{dirOrZipFile, f})
   114  	fake.recordInvocation("ProcessPath", []interface{}{dirOrZipFile, f})
   115  	fake.processPathMutex.Unlock()
   116  	if fake.ProcessPathStub != nil {
   117  		return fake.ProcessPathStub(dirOrZipFile, f)
   118  	} else {
   119  		return fake.processPathReturns.result1
   120  	}
   121  }
   122  
   123  func (fake *FakePushActor) ProcessPathCallCount() int {
   124  	fake.processPathMutex.RLock()
   125  	defer fake.processPathMutex.RUnlock()
   126  	return len(fake.processPathArgsForCall)
   127  }
   128  
   129  func (fake *FakePushActor) ProcessPathArgsForCall(i int) (string, func(string) error) {
   130  	fake.processPathMutex.RLock()
   131  	defer fake.processPathMutex.RUnlock()
   132  	return fake.processPathArgsForCall[i].dirOrZipFile, fake.processPathArgsForCall[i].f
   133  }
   134  
   135  func (fake *FakePushActor) ProcessPathReturns(result1 error) {
   136  	fake.ProcessPathStub = nil
   137  	fake.processPathReturns = struct {
   138  		result1 error
   139  	}{result1}
   140  }
   141  
   142  func (fake *FakePushActor) GatherFiles(localFiles []models.AppFileFields, appDir string, uploadDir string, useCache bool) ([]resources.AppFileResource, bool, error) {
   143  	var localFilesCopy []models.AppFileFields
   144  	if localFiles != nil {
   145  		localFilesCopy = make([]models.AppFileFields, len(localFiles))
   146  		copy(localFilesCopy, localFiles)
   147  	}
   148  	fake.gatherFilesMutex.Lock()
   149  	fake.gatherFilesArgsForCall = append(fake.gatherFilesArgsForCall, struct {
   150  		localFiles []models.AppFileFields
   151  		appDir     string
   152  		uploadDir  string
   153  		useCache   bool
   154  	}{localFilesCopy, appDir, uploadDir, useCache})
   155  	fake.recordInvocation("GatherFiles", []interface{}{localFilesCopy, appDir, uploadDir, useCache})
   156  	fake.gatherFilesMutex.Unlock()
   157  	if fake.GatherFilesStub != nil {
   158  		return fake.GatherFilesStub(localFiles, appDir, uploadDir, useCache)
   159  	} else {
   160  		return fake.gatherFilesReturns.result1, fake.gatherFilesReturns.result2, fake.gatherFilesReturns.result3
   161  	}
   162  }
   163  
   164  func (fake *FakePushActor) GatherFilesCallCount() int {
   165  	fake.gatherFilesMutex.RLock()
   166  	defer fake.gatherFilesMutex.RUnlock()
   167  	return len(fake.gatherFilesArgsForCall)
   168  }
   169  
   170  func (fake *FakePushActor) GatherFilesArgsForCall(i int) ([]models.AppFileFields, string, string, bool) {
   171  	fake.gatherFilesMutex.RLock()
   172  	defer fake.gatherFilesMutex.RUnlock()
   173  	return fake.gatherFilesArgsForCall[i].localFiles, fake.gatherFilesArgsForCall[i].appDir, fake.gatherFilesArgsForCall[i].uploadDir, fake.gatherFilesArgsForCall[i].useCache
   174  }
   175  
   176  func (fake *FakePushActor) GatherFilesReturns(result1 []resources.AppFileResource, result2 bool, result3 error) {
   177  	fake.GatherFilesStub = nil
   178  	fake.gatherFilesReturns = struct {
   179  		result1 []resources.AppFileResource
   180  		result2 bool
   181  		result3 error
   182  	}{result1, result2, result3}
   183  }
   184  
   185  func (fake *FakePushActor) ValidateAppParams(apps []models.AppParams) []error {
   186  	var appsCopy []models.AppParams
   187  	if apps != nil {
   188  		appsCopy = make([]models.AppParams, len(apps))
   189  		copy(appsCopy, apps)
   190  	}
   191  	fake.validateAppParamsMutex.Lock()
   192  	fake.validateAppParamsArgsForCall = append(fake.validateAppParamsArgsForCall, struct {
   193  		apps []models.AppParams
   194  	}{appsCopy})
   195  	fake.recordInvocation("ValidateAppParams", []interface{}{appsCopy})
   196  	fake.validateAppParamsMutex.Unlock()
   197  	if fake.ValidateAppParamsStub != nil {
   198  		return fake.ValidateAppParamsStub(apps)
   199  	} else {
   200  		return fake.validateAppParamsReturns.result1
   201  	}
   202  }
   203  
   204  func (fake *FakePushActor) ValidateAppParamsCallCount() int {
   205  	fake.validateAppParamsMutex.RLock()
   206  	defer fake.validateAppParamsMutex.RUnlock()
   207  	return len(fake.validateAppParamsArgsForCall)
   208  }
   209  
   210  func (fake *FakePushActor) ValidateAppParamsArgsForCall(i int) []models.AppParams {
   211  	fake.validateAppParamsMutex.RLock()
   212  	defer fake.validateAppParamsMutex.RUnlock()
   213  	return fake.validateAppParamsArgsForCall[i].apps
   214  }
   215  
   216  func (fake *FakePushActor) ValidateAppParamsReturns(result1 []error) {
   217  	fake.ValidateAppParamsStub = nil
   218  	fake.validateAppParamsReturns = struct {
   219  		result1 []error
   220  	}{result1}
   221  }
   222  
   223  func (fake *FakePushActor) MapManifestRoute(routeName string, app models.Application, appParamsFromContext models.AppParams) error {
   224  	fake.mapManifestRouteMutex.Lock()
   225  	fake.mapManifestRouteArgsForCall = append(fake.mapManifestRouteArgsForCall, struct {
   226  		routeName            string
   227  		app                  models.Application
   228  		appParamsFromContext models.AppParams
   229  	}{routeName, app, appParamsFromContext})
   230  	fake.recordInvocation("MapManifestRoute", []interface{}{routeName, app, appParamsFromContext})
   231  	fake.mapManifestRouteMutex.Unlock()
   232  	if fake.MapManifestRouteStub != nil {
   233  		return fake.MapManifestRouteStub(routeName, app, appParamsFromContext)
   234  	} else {
   235  		return fake.mapManifestRouteReturns.result1
   236  	}
   237  }
   238  
   239  func (fake *FakePushActor) MapManifestRouteCallCount() int {
   240  	fake.mapManifestRouteMutex.RLock()
   241  	defer fake.mapManifestRouteMutex.RUnlock()
   242  	return len(fake.mapManifestRouteArgsForCall)
   243  }
   244  
   245  func (fake *FakePushActor) MapManifestRouteArgsForCall(i int) (string, models.Application, models.AppParams) {
   246  	fake.mapManifestRouteMutex.RLock()
   247  	defer fake.mapManifestRouteMutex.RUnlock()
   248  	return fake.mapManifestRouteArgsForCall[i].routeName, fake.mapManifestRouteArgsForCall[i].app, fake.mapManifestRouteArgsForCall[i].appParamsFromContext
   249  }
   250  
   251  func (fake *FakePushActor) MapManifestRouteReturns(result1 error) {
   252  	fake.MapManifestRouteStub = nil
   253  	fake.mapManifestRouteReturns = struct {
   254  		result1 error
   255  	}{result1}
   256  }
   257  
   258  func (fake *FakePushActor) Invocations() map[string][][]interface{} {
   259  	fake.invocationsMutex.RLock()
   260  	defer fake.invocationsMutex.RUnlock()
   261  	fake.uploadAppMutex.RLock()
   262  	defer fake.uploadAppMutex.RUnlock()
   263  	fake.processPathMutex.RLock()
   264  	defer fake.processPathMutex.RUnlock()
   265  	fake.gatherFilesMutex.RLock()
   266  	defer fake.gatherFilesMutex.RUnlock()
   267  	fake.validateAppParamsMutex.RLock()
   268  	defer fake.validateAppParamsMutex.RUnlock()
   269  	fake.mapManifestRouteMutex.RLock()
   270  	defer fake.mapManifestRouteMutex.RUnlock()
   271  	return fake.invocations
   272  }
   273  
   274  func (fake *FakePushActor) recordInvocation(key string, args []interface{}) {
   275  	fake.invocationsMutex.Lock()
   276  	defer fake.invocationsMutex.Unlock()
   277  	if fake.invocations == nil {
   278  		fake.invocations = map[string][][]interface{}{}
   279  	}
   280  	if fake.invocations[key] == nil {
   281  		fake.invocations[key] = [][]interface{}{}
   282  	}
   283  	fake.invocations[key] = append(fake.invocations[key], args)
   284  }
   285  
   286  var _ actors.PushActor = new(FakePushActor)