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