github.com/jasonkeene/cli@v6.14.1-0.20160816203908-ca5715166dfb+incompatible/cf/api/apifakes/fake_buildpack_repository.go (about)

     1  // This file was generated by counterfeiter
     2  package apifakes
     3  
     4  import (
     5  	"sync"
     6  
     7  	"github.com/cloudfoundry/cli/cf/api"
     8  	"github.com/cloudfoundry/cli/cf/models"
     9  )
    10  
    11  type FakeBuildpackRepository struct {
    12  	FindByNameStub        func(name string) (buildpack models.Buildpack, apiErr error)
    13  	findByNameMutex       sync.RWMutex
    14  	findByNameArgsForCall []struct {
    15  		name string
    16  	}
    17  	findByNameReturns struct {
    18  		result1 models.Buildpack
    19  		result2 error
    20  	}
    21  	ListBuildpacksStub        func(func(models.Buildpack) bool) error
    22  	listBuildpacksMutex       sync.RWMutex
    23  	listBuildpacksArgsForCall []struct {
    24  		arg1 func(models.Buildpack) bool
    25  	}
    26  	listBuildpacksReturns struct {
    27  		result1 error
    28  	}
    29  	CreateStub        func(name string, position *int, enabled *bool, locked *bool) (createdBuildpack models.Buildpack, apiErr error)
    30  	createMutex       sync.RWMutex
    31  	createArgsForCall []struct {
    32  		name     string
    33  		position *int
    34  		enabled  *bool
    35  		locked   *bool
    36  	}
    37  	createReturns struct {
    38  		result1 models.Buildpack
    39  		result2 error
    40  	}
    41  	DeleteStub        func(buildpackGUID string) (apiErr error)
    42  	deleteMutex       sync.RWMutex
    43  	deleteArgsForCall []struct {
    44  		buildpackGUID string
    45  	}
    46  	deleteReturns struct {
    47  		result1 error
    48  	}
    49  	UpdateStub        func(buildpack models.Buildpack) (updatedBuildpack models.Buildpack, apiErr error)
    50  	updateMutex       sync.RWMutex
    51  	updateArgsForCall []struct {
    52  		buildpack models.Buildpack
    53  	}
    54  	updateReturns struct {
    55  		result1 models.Buildpack
    56  		result2 error
    57  	}
    58  	invocations      map[string][][]interface{}
    59  	invocationsMutex sync.RWMutex
    60  }
    61  
    62  func (fake *FakeBuildpackRepository) FindByName(name string) (buildpack models.Buildpack, apiErr error) {
    63  	fake.findByNameMutex.Lock()
    64  	fake.findByNameArgsForCall = append(fake.findByNameArgsForCall, struct {
    65  		name string
    66  	}{name})
    67  	fake.recordInvocation("FindByName", []interface{}{name})
    68  	fake.findByNameMutex.Unlock()
    69  	if fake.FindByNameStub != nil {
    70  		return fake.FindByNameStub(name)
    71  	} else {
    72  		return fake.findByNameReturns.result1, fake.findByNameReturns.result2
    73  	}
    74  }
    75  
    76  func (fake *FakeBuildpackRepository) FindByNameCallCount() int {
    77  	fake.findByNameMutex.RLock()
    78  	defer fake.findByNameMutex.RUnlock()
    79  	return len(fake.findByNameArgsForCall)
    80  }
    81  
    82  func (fake *FakeBuildpackRepository) FindByNameArgsForCall(i int) string {
    83  	fake.findByNameMutex.RLock()
    84  	defer fake.findByNameMutex.RUnlock()
    85  	return fake.findByNameArgsForCall[i].name
    86  }
    87  
    88  func (fake *FakeBuildpackRepository) FindByNameReturns(result1 models.Buildpack, result2 error) {
    89  	fake.FindByNameStub = nil
    90  	fake.findByNameReturns = struct {
    91  		result1 models.Buildpack
    92  		result2 error
    93  	}{result1, result2}
    94  }
    95  
    96  func (fake *FakeBuildpackRepository) ListBuildpacks(arg1 func(models.Buildpack) bool) error {
    97  	fake.listBuildpacksMutex.Lock()
    98  	fake.listBuildpacksArgsForCall = append(fake.listBuildpacksArgsForCall, struct {
    99  		arg1 func(models.Buildpack) bool
   100  	}{arg1})
   101  	fake.recordInvocation("ListBuildpacks", []interface{}{arg1})
   102  	fake.listBuildpacksMutex.Unlock()
   103  	if fake.ListBuildpacksStub != nil {
   104  		return fake.ListBuildpacksStub(arg1)
   105  	} else {
   106  		return fake.listBuildpacksReturns.result1
   107  	}
   108  }
   109  
   110  func (fake *FakeBuildpackRepository) ListBuildpacksCallCount() int {
   111  	fake.listBuildpacksMutex.RLock()
   112  	defer fake.listBuildpacksMutex.RUnlock()
   113  	return len(fake.listBuildpacksArgsForCall)
   114  }
   115  
   116  func (fake *FakeBuildpackRepository) ListBuildpacksArgsForCall(i int) func(models.Buildpack) bool {
   117  	fake.listBuildpacksMutex.RLock()
   118  	defer fake.listBuildpacksMutex.RUnlock()
   119  	return fake.listBuildpacksArgsForCall[i].arg1
   120  }
   121  
   122  func (fake *FakeBuildpackRepository) ListBuildpacksReturns(result1 error) {
   123  	fake.ListBuildpacksStub = nil
   124  	fake.listBuildpacksReturns = struct {
   125  		result1 error
   126  	}{result1}
   127  }
   128  
   129  func (fake *FakeBuildpackRepository) Create(name string, position *int, enabled *bool, locked *bool) (createdBuildpack models.Buildpack, apiErr error) {
   130  	fake.createMutex.Lock()
   131  	fake.createArgsForCall = append(fake.createArgsForCall, struct {
   132  		name     string
   133  		position *int
   134  		enabled  *bool
   135  		locked   *bool
   136  	}{name, position, enabled, locked})
   137  	fake.recordInvocation("Create", []interface{}{name, position, enabled, locked})
   138  	fake.createMutex.Unlock()
   139  	if fake.CreateStub != nil {
   140  		return fake.CreateStub(name, position, enabled, locked)
   141  	} else {
   142  		return fake.createReturns.result1, fake.createReturns.result2
   143  	}
   144  }
   145  
   146  func (fake *FakeBuildpackRepository) CreateCallCount() int {
   147  	fake.createMutex.RLock()
   148  	defer fake.createMutex.RUnlock()
   149  	return len(fake.createArgsForCall)
   150  }
   151  
   152  func (fake *FakeBuildpackRepository) CreateArgsForCall(i int) (string, *int, *bool, *bool) {
   153  	fake.createMutex.RLock()
   154  	defer fake.createMutex.RUnlock()
   155  	return fake.createArgsForCall[i].name, fake.createArgsForCall[i].position, fake.createArgsForCall[i].enabled, fake.createArgsForCall[i].locked
   156  }
   157  
   158  func (fake *FakeBuildpackRepository) CreateReturns(result1 models.Buildpack, result2 error) {
   159  	fake.CreateStub = nil
   160  	fake.createReturns = struct {
   161  		result1 models.Buildpack
   162  		result2 error
   163  	}{result1, result2}
   164  }
   165  
   166  func (fake *FakeBuildpackRepository) Delete(buildpackGUID string) (apiErr error) {
   167  	fake.deleteMutex.Lock()
   168  	fake.deleteArgsForCall = append(fake.deleteArgsForCall, struct {
   169  		buildpackGUID string
   170  	}{buildpackGUID})
   171  	fake.recordInvocation("Delete", []interface{}{buildpackGUID})
   172  	fake.deleteMutex.Unlock()
   173  	if fake.DeleteStub != nil {
   174  		return fake.DeleteStub(buildpackGUID)
   175  	} else {
   176  		return fake.deleteReturns.result1
   177  	}
   178  }
   179  
   180  func (fake *FakeBuildpackRepository) DeleteCallCount() int {
   181  	fake.deleteMutex.RLock()
   182  	defer fake.deleteMutex.RUnlock()
   183  	return len(fake.deleteArgsForCall)
   184  }
   185  
   186  func (fake *FakeBuildpackRepository) DeleteArgsForCall(i int) string {
   187  	fake.deleteMutex.RLock()
   188  	defer fake.deleteMutex.RUnlock()
   189  	return fake.deleteArgsForCall[i].buildpackGUID
   190  }
   191  
   192  func (fake *FakeBuildpackRepository) DeleteReturns(result1 error) {
   193  	fake.DeleteStub = nil
   194  	fake.deleteReturns = struct {
   195  		result1 error
   196  	}{result1}
   197  }
   198  
   199  func (fake *FakeBuildpackRepository) Update(buildpack models.Buildpack) (updatedBuildpack models.Buildpack, apiErr error) {
   200  	fake.updateMutex.Lock()
   201  	fake.updateArgsForCall = append(fake.updateArgsForCall, struct {
   202  		buildpack models.Buildpack
   203  	}{buildpack})
   204  	fake.recordInvocation("Update", []interface{}{buildpack})
   205  	fake.updateMutex.Unlock()
   206  	if fake.UpdateStub != nil {
   207  		return fake.UpdateStub(buildpack)
   208  	} else {
   209  		return fake.updateReturns.result1, fake.updateReturns.result2
   210  	}
   211  }
   212  
   213  func (fake *FakeBuildpackRepository) UpdateCallCount() int {
   214  	fake.updateMutex.RLock()
   215  	defer fake.updateMutex.RUnlock()
   216  	return len(fake.updateArgsForCall)
   217  }
   218  
   219  func (fake *FakeBuildpackRepository) UpdateArgsForCall(i int) models.Buildpack {
   220  	fake.updateMutex.RLock()
   221  	defer fake.updateMutex.RUnlock()
   222  	return fake.updateArgsForCall[i].buildpack
   223  }
   224  
   225  func (fake *FakeBuildpackRepository) UpdateReturns(result1 models.Buildpack, result2 error) {
   226  	fake.UpdateStub = nil
   227  	fake.updateReturns = struct {
   228  		result1 models.Buildpack
   229  		result2 error
   230  	}{result1, result2}
   231  }
   232  
   233  func (fake *FakeBuildpackRepository) Invocations() map[string][][]interface{} {
   234  	fake.invocationsMutex.RLock()
   235  	defer fake.invocationsMutex.RUnlock()
   236  	fake.findByNameMutex.RLock()
   237  	defer fake.findByNameMutex.RUnlock()
   238  	fake.listBuildpacksMutex.RLock()
   239  	defer fake.listBuildpacksMutex.RUnlock()
   240  	fake.createMutex.RLock()
   241  	defer fake.createMutex.RUnlock()
   242  	fake.deleteMutex.RLock()
   243  	defer fake.deleteMutex.RUnlock()
   244  	fake.updateMutex.RLock()
   245  	defer fake.updateMutex.RUnlock()
   246  	return fake.invocations
   247  }
   248  
   249  func (fake *FakeBuildpackRepository) recordInvocation(key string, args []interface{}) {
   250  	fake.invocationsMutex.Lock()
   251  	defer fake.invocationsMutex.Unlock()
   252  	if fake.invocations == nil {
   253  		fake.invocations = map[string][][]interface{}{}
   254  	}
   255  	if fake.invocations[key] == nil {
   256  		fake.invocations[key] = [][]interface{}{}
   257  	}
   258  	fake.invocations[key] = append(fake.invocations[key], args)
   259  }
   260  
   261  var _ api.BuildpackRepository = new(FakeBuildpackRepository)