terraform: Test that validate gets a config for provisioners
This commit is contained in:
parent
abd5977988
commit
c8bc5658ab
|
@ -161,6 +161,12 @@ func TestContextValidate_provisionerConfig_good(t *testing.T) {
|
||||||
config := testConfig(t, "validate-bad-prov-conf")
|
config := testConfig(t, "validate-bad-prov-conf")
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
pr := testProvisioner()
|
pr := testProvisioner()
|
||||||
|
pr.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
|
||||||
|
if c == nil {
|
||||||
|
t.Fatalf("missing resource config for provisioner")
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
c := testContext(t, &ContextOpts{
|
c := testContext(t, &ContextOpts{
|
||||||
Config: config,
|
Config: config,
|
||||||
Providers: map[string]ResourceProviderFactory{
|
Providers: map[string]ResourceProviderFactory{
|
||||||
|
|
|
@ -15,6 +15,7 @@ type MockResourceProvisioner struct {
|
||||||
|
|
||||||
ValidateCalled bool
|
ValidateCalled bool
|
||||||
ValidateConfig *ResourceConfig
|
ValidateConfig *ResourceConfig
|
||||||
|
ValidateFn func(c *ResourceConfig) ([]string, []error)
|
||||||
ValidateReturnWarns []string
|
ValidateReturnWarns []string
|
||||||
ValidateReturnErrors []error
|
ValidateReturnErrors []error
|
||||||
}
|
}
|
||||||
|
@ -22,6 +23,9 @@ type MockResourceProvisioner struct {
|
||||||
func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error) {
|
func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error) {
|
||||||
p.ValidateCalled = true
|
p.ValidateCalled = true
|
||||||
p.ValidateConfig = c
|
p.ValidateConfig = c
|
||||||
|
if p.ValidateFn != nil {
|
||||||
|
return p.ValidateFn(c)
|
||||||
|
}
|
||||||
return p.ValidateReturnWarns, p.ValidateReturnErrors
|
return p.ValidateReturnWarns, p.ValidateReturnErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue