From c8bc5658ab2d56563209eb7d7e2d7f532afc4a87 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 9 Jul 2014 15:02:00 -0700 Subject: [PATCH] terraform: Test that validate gets a config for provisioners --- terraform/context_test.go | 6 ++++++ terraform/resource_provisioner_mock.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/terraform/context_test.go b/terraform/context_test.go index 906bff7d9..793a9293d 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -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{ diff --git a/terraform/resource_provisioner_mock.go b/terraform/resource_provisioner_mock.go index e50342416..2f9a70b9f 100644 --- a/terraform/resource_provisioner_mock.go +++ b/terraform/resource_provisioner_mock.go @@ -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 }