terraform: Test that validate gets a config for provisioners

This commit is contained in:
Armon Dadgar 2014-07-09 15:02:00 -07:00
parent abd5977988
commit c8bc5658ab
2 changed files with 10 additions and 0 deletions

View File

@ -161,6 +161,12 @@ func TestContextValidate_provisionerConfig_good(t *testing.T) {
config := testConfig(t, "validate-bad-prov-conf")
p := testProvider("aws")
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{
Config: config,
Providers: map[string]ResourceProviderFactory{

View File

@ -15,6 +15,7 @@ type MockResourceProvisioner struct {
ValidateCalled bool
ValidateConfig *ResourceConfig
ValidateFn func(c *ResourceConfig) ([]string, []error)
ValidateReturnWarns []string
ValidateReturnErrors []error
}
@ -22,6 +23,9 @@ type MockResourceProvisioner struct {
func (p *MockResourceProvisioner) Validate(c *ResourceConfig) ([]string, []error) {
p.ValidateCalled = true
p.ValidateConfig = c
if p.ValidateFn != nil {
return p.ValidateFn(c)
}
return p.ValidateReturnWarns, p.ValidateReturnErrors
}