terraform: implement Stop in the mock and shadow

This commit is contained in:
Mitchell Hashimoto 2016-10-23 17:33:11 -07:00
parent 60140b28f4
commit d338a1ef88
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 24 additions and 0 deletions

View File

@ -56,6 +56,9 @@ type MockResourceProvider struct {
ReadDataDiffFn func(*InstanceInfo, *ResourceConfig) (*InstanceDiff, error) ReadDataDiffFn func(*InstanceInfo, *ResourceConfig) (*InstanceDiff, error)
ReadDataDiffReturn *InstanceDiff ReadDataDiffReturn *InstanceDiff
ReadDataDiffReturnError error ReadDataDiffReturnError error
StopCalled bool
StopFn func() error
StopReturnError error
DataSourcesCalled bool DataSourcesCalled bool
DataSourcesReturn []DataSource DataSourcesReturn []DataSource
ValidateCalled bool ValidateCalled bool
@ -141,6 +144,18 @@ func (p *MockResourceProvider) Configure(c *ResourceConfig) error {
return p.ConfigureReturnError return p.ConfigureReturnError
} }
func (p *MockResourceProvider) Stop() error {
p.Lock()
defer p.Unlock()
p.StopCalled = true
if p.StopFn != nil {
return p.StopFn()
}
return p.StopReturnError
}
func (p *MockResourceProvider) Apply( func (p *MockResourceProvider) Apply(
info *InstanceInfo, info *InstanceInfo,
state *InstanceState, state *InstanceState,

View File

@ -107,6 +107,10 @@ func (p *shadowResourceProviderReal) Configure(c *ResourceConfig) error {
return err return err
} }
func (p *shadowResourceProviderReal) Stop() error {
return p.ResourceProvider.Stop()
}
func (p *shadowResourceProviderReal) ValidateResource( func (p *shadowResourceProviderReal) ValidateResource(
t string, c *ResourceConfig) ([]string, []error) { t string, c *ResourceConfig) ([]string, []error) {
key := t key := t
@ -441,6 +445,11 @@ func (p *shadowResourceProviderShadow) Configure(c *ResourceConfig) error {
return result.Result return result.Result
} }
// Stop returns immediately.
func (p *shadowResourceProviderShadow) Stop() error {
return nil
}
func (p *shadowResourceProviderShadow) ValidateResource(t string, c *ResourceConfig) ([]string, []error) { func (p *shadowResourceProviderShadow) ValidateResource(t string, c *ResourceConfig) ([]string, []error) {
// Unique key // Unique key
key := t key := t