5 // MockResourceProvisioner implements ResourceProvisioner but mocks out all the
6 // calls for testing purposes.
7 type MockResourceProvisioner struct {
9 // Anything you want, in case you need to store extra data with the mock.
14 ApplyState *InstanceState
15 ApplyConfig *ResourceConfig
16 ApplyFn func(*InstanceState, *ResourceConfig) error
17 ApplyReturnError error
20 ValidateConfig *ResourceConfig
21 ValidateFn func(c *ResourceConfig) ([]string, []error)
22 ValidateReturnWarns []string
23 ValidateReturnErrors []error
30 func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error) {
34 p.ValidateCalled = true
36 if p.ValidateFn != nil {
37 return p.ValidateFn(c)
39 return p.ValidateReturnWarns, p.ValidateReturnErrors
42 func (p *MockResourceProvisioner) Apply(
45 c *ResourceConfig) error {
49 p.ApplyOutput = output
59 return p.ApplyReturnError
62 func (p *MockResourceProvisioner) Stop() error {
71 return p.StopReturnError