github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/appfiles/appfilesfakes/fake_zipper.go (about)

     1  // This file was generated by counterfeiter
     2  package appfilesfakes
     3  
     4  import (
     5  	"os"
     6  	"sync"
     7  
     8  	"code.cloudfoundry.org/cli/cf/appfiles"
     9  )
    10  
    11  type FakeZipper struct {
    12  	ZipStub        func(dirToZip string, targetFile *os.File) (err error)
    13  	zipMutex       sync.RWMutex
    14  	zipArgsForCall []struct {
    15  		dirToZip   string
    16  		targetFile *os.File
    17  	}
    18  	zipReturns struct {
    19  		result1 error
    20  	}
    21  	IsZipFileStub        func(path string) bool
    22  	isZipFileMutex       sync.RWMutex
    23  	isZipFileArgsForCall []struct {
    24  		path string
    25  	}
    26  	isZipFileReturns struct {
    27  		result1 bool
    28  	}
    29  	UnzipStub        func(appDir string, destDir string) (err error)
    30  	unzipMutex       sync.RWMutex
    31  	unzipArgsForCall []struct {
    32  		appDir  string
    33  		destDir string
    34  	}
    35  	unzipReturns struct {
    36  		result1 error
    37  	}
    38  	GetZipSizeStub        func(zipFile *os.File) (int64, error)
    39  	getZipSizeMutex       sync.RWMutex
    40  	getZipSizeArgsForCall []struct {
    41  		zipFile *os.File
    42  	}
    43  	getZipSizeReturns struct {
    44  		result1 int64
    45  		result2 error
    46  	}
    47  	invocations      map[string][][]interface{}
    48  	invocationsMutex sync.RWMutex
    49  }
    50  
    51  func (fake *FakeZipper) Zip(dirToZip string, targetFile *os.File) (err error) {
    52  	fake.zipMutex.Lock()
    53  	fake.zipArgsForCall = append(fake.zipArgsForCall, struct {
    54  		dirToZip   string
    55  		targetFile *os.File
    56  	}{dirToZip, targetFile})
    57  	fake.recordInvocation("Zip", []interface{}{dirToZip, targetFile})
    58  	fake.zipMutex.Unlock()
    59  	if fake.ZipStub != nil {
    60  		return fake.ZipStub(dirToZip, targetFile)
    61  	} else {
    62  		return fake.zipReturns.result1
    63  	}
    64  }
    65  
    66  func (fake *FakeZipper) ZipCallCount() int {
    67  	fake.zipMutex.RLock()
    68  	defer fake.zipMutex.RUnlock()
    69  	return len(fake.zipArgsForCall)
    70  }
    71  
    72  func (fake *FakeZipper) ZipArgsForCall(i int) (string, *os.File) {
    73  	fake.zipMutex.RLock()
    74  	defer fake.zipMutex.RUnlock()
    75  	return fake.zipArgsForCall[i].dirToZip, fake.zipArgsForCall[i].targetFile
    76  }
    77  
    78  func (fake *FakeZipper) ZipReturns(result1 error) {
    79  	fake.ZipStub = nil
    80  	fake.zipReturns = struct {
    81  		result1 error
    82  	}{result1}
    83  }
    84  
    85  func (fake *FakeZipper) IsZipFile(path string) bool {
    86  	fake.isZipFileMutex.Lock()
    87  	fake.isZipFileArgsForCall = append(fake.isZipFileArgsForCall, struct {
    88  		path string
    89  	}{path})
    90  	fake.recordInvocation("IsZipFile", []interface{}{path})
    91  	fake.isZipFileMutex.Unlock()
    92  	if fake.IsZipFileStub != nil {
    93  		return fake.IsZipFileStub(path)
    94  	} else {
    95  		return fake.isZipFileReturns.result1
    96  	}
    97  }
    98  
    99  func (fake *FakeZipper) IsZipFileCallCount() int {
   100  	fake.isZipFileMutex.RLock()
   101  	defer fake.isZipFileMutex.RUnlock()
   102  	return len(fake.isZipFileArgsForCall)
   103  }
   104  
   105  func (fake *FakeZipper) IsZipFileArgsForCall(i int) string {
   106  	fake.isZipFileMutex.RLock()
   107  	defer fake.isZipFileMutex.RUnlock()
   108  	return fake.isZipFileArgsForCall[i].path
   109  }
   110  
   111  func (fake *FakeZipper) IsZipFileReturns(result1 bool) {
   112  	fake.IsZipFileStub = nil
   113  	fake.isZipFileReturns = struct {
   114  		result1 bool
   115  	}{result1}
   116  }
   117  
   118  func (fake *FakeZipper) Unzip(appDir string, destDir string) (err error) {
   119  	fake.unzipMutex.Lock()
   120  	fake.unzipArgsForCall = append(fake.unzipArgsForCall, struct {
   121  		appDir  string
   122  		destDir string
   123  	}{appDir, destDir})
   124  	fake.recordInvocation("Unzip", []interface{}{appDir, destDir})
   125  	fake.unzipMutex.Unlock()
   126  	if fake.UnzipStub != nil {
   127  		return fake.UnzipStub(appDir, destDir)
   128  	} else {
   129  		return fake.unzipReturns.result1
   130  	}
   131  }
   132  
   133  func (fake *FakeZipper) UnzipCallCount() int {
   134  	fake.unzipMutex.RLock()
   135  	defer fake.unzipMutex.RUnlock()
   136  	return len(fake.unzipArgsForCall)
   137  }
   138  
   139  func (fake *FakeZipper) UnzipArgsForCall(i int) (string, string) {
   140  	fake.unzipMutex.RLock()
   141  	defer fake.unzipMutex.RUnlock()
   142  	return fake.unzipArgsForCall[i].appDir, fake.unzipArgsForCall[i].destDir
   143  }
   144  
   145  func (fake *FakeZipper) UnzipReturns(result1 error) {
   146  	fake.UnzipStub = nil
   147  	fake.unzipReturns = struct {
   148  		result1 error
   149  	}{result1}
   150  }
   151  
   152  func (fake *FakeZipper) GetZipSize(zipFile *os.File) (int64, error) {
   153  	fake.getZipSizeMutex.Lock()
   154  	fake.getZipSizeArgsForCall = append(fake.getZipSizeArgsForCall, struct {
   155  		zipFile *os.File
   156  	}{zipFile})
   157  	fake.recordInvocation("GetZipSize", []interface{}{zipFile})
   158  	fake.getZipSizeMutex.Unlock()
   159  	if fake.GetZipSizeStub != nil {
   160  		return fake.GetZipSizeStub(zipFile)
   161  	} else {
   162  		return fake.getZipSizeReturns.result1, fake.getZipSizeReturns.result2
   163  	}
   164  }
   165  
   166  func (fake *FakeZipper) GetZipSizeCallCount() int {
   167  	fake.getZipSizeMutex.RLock()
   168  	defer fake.getZipSizeMutex.RUnlock()
   169  	return len(fake.getZipSizeArgsForCall)
   170  }
   171  
   172  func (fake *FakeZipper) GetZipSizeArgsForCall(i int) *os.File {
   173  	fake.getZipSizeMutex.RLock()
   174  	defer fake.getZipSizeMutex.RUnlock()
   175  	return fake.getZipSizeArgsForCall[i].zipFile
   176  }
   177  
   178  func (fake *FakeZipper) GetZipSizeReturns(result1 int64, result2 error) {
   179  	fake.GetZipSizeStub = nil
   180  	fake.getZipSizeReturns = struct {
   181  		result1 int64
   182  		result2 error
   183  	}{result1, result2}
   184  }
   185  
   186  func (fake *FakeZipper) Invocations() map[string][][]interface{} {
   187  	fake.invocationsMutex.RLock()
   188  	defer fake.invocationsMutex.RUnlock()
   189  	fake.zipMutex.RLock()
   190  	defer fake.zipMutex.RUnlock()
   191  	fake.isZipFileMutex.RLock()
   192  	defer fake.isZipFileMutex.RUnlock()
   193  	fake.unzipMutex.RLock()
   194  	defer fake.unzipMutex.RUnlock()
   195  	fake.getZipSizeMutex.RLock()
   196  	defer fake.getZipSizeMutex.RUnlock()
   197  	return fake.invocations
   198  }
   199  
   200  func (fake *FakeZipper) recordInvocation(key string, args []interface{}) {
   201  	fake.invocationsMutex.Lock()
   202  	defer fake.invocationsMutex.Unlock()
   203  	if fake.invocations == nil {
   204  		fake.invocations = map[string][][]interface{}{}
   205  	}
   206  	if fake.invocations[key] == nil {
   207  		fake.invocations[key] = [][]interface{}{}
   208  	}
   209  	fake.invocations[key] = append(fake.invocations[key], args)
   210  }
   211  
   212  var _ appfiles.Zipper = new(FakeZipper)