-
Notifications
You must be signed in to change notification settings - Fork 114
/
fake_bundle.go
80 lines (63 loc) · 1.83 KB
/
fake_bundle.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
70
71
72
73
74
75
76
77
78
79
80
package fakes
import (
boshsys "github.com/cloudfoundry/bosh-utils/system"
)
type FakeBundleInstallCallBack func()
type FakeBundle struct {
ActionsCalled []string
InstallSourcePath string
InstallCallBack FakeBundleInstallCallBack
InstallFs boshsys.FileSystem
InstallPath string
InstallError error
Installed bool
IsInstalledErr error
GetDirPath string
GetDirFs boshsys.FileSystem
GetDirError error
EnablePath string
EnableFs boshsys.FileSystem
EnableError error
Enabled bool
DisableErr error
UninstallErr error
}
func NewFakeBundle() (bundle *FakeBundle) {
bundle = &FakeBundle{
ActionsCalled: []string{},
}
return
}
func (s *FakeBundle) Install(sourcePath string) (boshsys.FileSystem, string, error) {
s.InstallSourcePath = sourcePath
s.Installed = true
s.ActionsCalled = append(s.ActionsCalled, "Install")
if s.InstallCallBack != nil {
s.InstallCallBack()
}
return s.InstallFs, s.InstallPath, s.InstallError
}
func (s *FakeBundle) InstallWithoutContents() (boshsys.FileSystem, string, error) {
s.Installed = true
s.ActionsCalled = append(s.ActionsCalled, "InstallWithoutContents")
return s.InstallFs, s.InstallPath, s.InstallError
}
func (s *FakeBundle) GetInstallPath() (boshsys.FileSystem, string, error) {
return s.GetDirFs, s.GetDirPath, s.GetDirError
}
func (s *FakeBundle) IsInstalled() (bool, error) {
return s.Installed, s.IsInstalledErr
}
func (s *FakeBundle) Enable() (boshsys.FileSystem, string, error) {
s.Enabled = true
s.ActionsCalled = append(s.ActionsCalled, "Enable")
return s.EnableFs, s.EnablePath, s.EnableError
}
func (s *FakeBundle) Disable() error {
s.ActionsCalled = append(s.ActionsCalled, "Disable")
return s.DisableErr
}
func (s *FakeBundle) Uninstall() error {
s.ActionsCalled = append(s.ActionsCalled, "Uninstall")
return s.UninstallErr
}