forked from cloudfoundry/bosh-bootloader
/
state_store.go
139 lines (109 loc) · 2.65 KB
/
state_store.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package fakes
import "github.com/cloudfoundry/bosh-bootloader/storage"
type StateStore struct {
SetCall struct {
CallCount int
Receives []SetCallReceive
Returns []SetCallReturn
}
GetCall struct {
CallCount int
Receives struct {
Dir string
}
Returns struct {
State storage.State
Error error
}
}
GetCloudConfigDirCall struct {
CallCount int
Returns struct {
Directory string
Error error
}
}
GetStateDirCall struct {
CallCount int
Returns struct {
Directory string
}
}
GetOldBblDirCall struct {
CallCount int
Returns struct {
Directory string
Error error
}
}
GetTerraformDirCall struct {
CallCount int
Returns struct {
Directory string
Error error
}
}
GetVarsDirCall struct {
CallCount int
Returns struct {
Directory string
Error error
}
}
GetDirectorDeploymentDirCall struct {
CallCount int
Returns struct {
Directory string
Error error
}
}
GetJumpboxDeploymentDirCall struct {
CallCount int
Returns struct {
Directory string
Error error
}
}
}
type SetCallReceive struct {
State storage.State
}
type SetCallReturn struct {
Error error
}
func (s *StateStore) Set(state storage.State) error {
s.SetCall.CallCount++
s.SetCall.Receives = append(s.SetCall.Receives, SetCallReceive{State: state})
if len(s.SetCall.Returns) < s.SetCall.CallCount {
return nil
}
return s.SetCall.Returns[s.SetCall.CallCount-1].Error
}
func (s *StateStore) GetCloudConfigDir() (string, error) {
s.GetCloudConfigDirCall.CallCount++
return s.GetCloudConfigDirCall.Returns.Directory, s.GetCloudConfigDirCall.Returns.Error
}
func (s *StateStore) GetStateDir() string {
s.GetStateDirCall.CallCount++
return s.GetStateDirCall.Returns.Directory
}
func (s *StateStore) GetOldBblDir() string {
s.GetOldBblDirCall.CallCount++
return s.GetOldBblDirCall.Returns.Directory
}
func (s *StateStore) GetTerraformDir() (string, error) {
s.GetTerraformDirCall.CallCount++
return s.GetTerraformDirCall.Returns.Directory, s.GetTerraformDirCall.Returns.Error
}
func (s *StateStore) GetVarsDir() (string, error) {
s.GetVarsDirCall.CallCount++
return s.GetVarsDirCall.Returns.Directory, s.GetVarsDirCall.Returns.Error
}
func (s *StateStore) GetDirectorDeploymentDir() (string, error) {
s.GetDirectorDeploymentDirCall.CallCount++
return s.GetDirectorDeploymentDirCall.Returns.Directory, s.GetDirectorDeploymentDirCall.Returns.Error
}
func (s *StateStore) GetJumpboxDeploymentDir() (string, error) {
s.GetJumpboxDeploymentDirCall.CallCount++
return s.GetJumpboxDeploymentDirCall.Returns.Directory, s.GetJumpboxDeploymentDirCall.Returns.Error
}