forked from cloudfoundry-attic/bosh-init
/
fake_compressor.go
46 lines (36 loc) · 1.35 KB
/
fake_compressor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package fakes
import (
boshcmd "github.com/cloudfoundry/bosh-agent/platform/commands"
)
type FakeCompressor struct {
CompressFilesInDirDir string
CompressFilesInDirTarballPath string
CompressFilesInDirErr error
DecompressFileToDirTarballPaths []string
DecompressFileToDirDirs []string
DecompressFileToDirOptions []boshcmd.CompressorOptions
DecompressFileToDirErr error
DecompressFileToDirCallBack func()
CleanUpTarballPath string
CleanUpErr error
}
func NewFakeCompressor() *FakeCompressor {
return &FakeCompressor{}
}
func (fc *FakeCompressor) CompressFilesInDir(dir string) (string, error) {
fc.CompressFilesInDirDir = dir
return fc.CompressFilesInDirTarballPath, fc.CompressFilesInDirErr
}
func (fc *FakeCompressor) DecompressFileToDir(tarballPath string, dir string, options boshcmd.CompressorOptions) (err error) {
fc.DecompressFileToDirTarballPaths = append(fc.DecompressFileToDirTarballPaths, tarballPath)
fc.DecompressFileToDirDirs = append(fc.DecompressFileToDirDirs, dir)
fc.DecompressFileToDirOptions = append(fc.DecompressFileToDirOptions, options)
if fc.DecompressFileToDirCallBack != nil {
fc.DecompressFileToDirCallBack()
}
return fc.DecompressFileToDirErr
}
func (fc *FakeCompressor) CleanUp(tarballPath string) error {
fc.CleanUpTarballPath = tarballPath
return fc.CleanUpErr
}