35
35
CredentialForCloudFunc func(string) (*cloud.CloudCredential, error)
36
36
AllCredentialsFunc func() (map[string]cloud.CloudCredential, error)
37
37
UpdateCredentialFunc func(cloudName string, details cloud.CloudCredential) error
39
BootstrapConfigForControllerFunc func(controllerName string) (*jujuclient.BootstrapConfig, error)
40
UpdateBootstrapConfigFunc func(controllerName string, cfg jujuclient.BootstrapConfig) error
40
43
func NewStubStore() *StubStore {
101
104
result.UpdateCredentialFunc = func(cloudName string, details cloud.CloudCredential) error {
102
105
return result.Stub.NextErr()
108
result.BootstrapConfigForControllerFunc = func(controllerName string) (*jujuclient.BootstrapConfig, error) {
109
return nil, result.Stub.NextErr()
111
result.UpdateBootstrapConfigFunc = func(controllerName string, cfg jujuclient.BootstrapConfig) error {
112
return result.Stub.NextErr()
117
// WrapClientStore wraps a ClientStore with a StubStore, where each method calls
118
// through to the wrapped store. This can be used to override specific
119
// methods, or just to check which calls have been made.
120
func WrapClientStore(underlying jujuclient.ClientStore) *StubStore {
121
stub := NewStubStore()
122
stub.AllControllersFunc = underlying.AllControllers
123
stub.ControllerByNameFunc = underlying.ControllerByName
124
stub.UpdateControllerFunc = underlying.UpdateController
125
stub.RemoveControllerFunc = underlying.RemoveController
126
stub.UpdateModelFunc = underlying.UpdateModel
127
stub.SetCurrentModelFunc = underlying.SetCurrentModel
128
stub.RemoveModelFunc = underlying.RemoveModel
129
stub.AllModelsFunc = underlying.AllModels
130
stub.CurrentModelFunc = underlying.CurrentModel
131
stub.ModelByNameFunc = underlying.ModelByName
132
stub.UpdateAccountFunc = underlying.UpdateAccount
133
stub.SetCurrentAccountFunc = underlying.SetCurrentAccount
134
stub.AllAccountsFunc = underlying.AllAccounts
135
stub.CurrentAccountFunc = underlying.CurrentAccount
136
stub.AccountByNameFunc = underlying.AccountByName
137
stub.RemoveAccountFunc = underlying.RemoveAccount
138
stub.BootstrapConfigForControllerFunc = underlying.BootstrapConfigForController
139
stub.UpdateBootstrapConfigFunc = underlying.UpdateBootstrapConfig
107
143
// AllControllers implements ControllersGetter.AllControllers
108
144
func (c *StubStore) AllControllers() (map[string]jujuclient.ControllerDetails, error) {
109
145
c.MethodCall(c, "AllControllers")
217
253
c.MethodCall(c, "UpdateCredential", cloudName, details)
218
254
return c.UpdateCredentialFunc(cloudName, details)
257
// BootstrapConfigForController implements BootstrapConfigGetter.
258
func (c *StubStore) BootstrapConfigForController(controllerName string) (*jujuclient.BootstrapConfig, error) {
259
c.MethodCall(c, "BootstrapConfigForController", controllerName)
260
return c.BootstrapConfigForControllerFunc(controllerName)
263
// UpdateBootstrapConfig implements BootstrapConfigUpdater.
264
func (c *StubStore) UpdateBootstrapConfig(controllerName string, cfg jujuclient.BootstrapConfig) error {
265
c.MethodCall(c, "UpdateBootstrapConfig", controllerName, cfg)
266
return c.UpdateBootstrapConfigFunc(controllerName, cfg)