forked from cloudfoundry-attic/bosh-ext-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_compressor.go
69 lines (53 loc) · 2.04 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package fakes
import (
boshcmd "github.com/cloudfoundry/bosh-utils/fileutil"
)
type FakeCompressor struct {
CompressFilesInDirDir string
CompressFilesInDirTarballPath string
CompressFilesInDirErr error
CompressFilesInDirCallBack func()
CompressSpecificFilesInDirDir string
CompressSpecificFilesInDirFiles []string
CompressSpecificFilesInDirTarballPath string
CompressSpecificFilesInDirErr error
CompressSpecificFilesInDirCallBack func()
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
if fc.CompressFilesInDirCallBack != nil {
fc.CompressFilesInDirCallBack()
}
return fc.CompressFilesInDirTarballPath, fc.CompressFilesInDirErr
}
func (fc *FakeCompressor) CompressSpecificFilesInDir(dir string, files []string) (string, error) {
fc.CompressSpecificFilesInDirDir = dir
fc.CompressSpecificFilesInDirFiles = files
if fc.CompressSpecificFilesInDirCallBack != nil {
fc.CompressSpecificFilesInDirCallBack()
}
return fc.CompressSpecificFilesInDirTarballPath, fc.CompressSpecificFilesInDirErr
}
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
}