From 1d64ce8ec0a3ebc93f5df50f5fd334b47da4f561 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sat, 13 Oct 2018 09:33:18 -0700 Subject: [PATCH] command: Fix "terraform validate" tests We now need to give a provider schema that the test fixtures conform to, so we can validate against it. --- command/validate_test.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/command/validate_test.go b/command/validate_test.go index a7412b0cf..7ab8f02b5 100644 --- a/command/validate_test.go +++ b/command/validate_test.go @@ -5,15 +5,40 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform/helper/copy" "github.com/mitchellh/cli" + "github.com/zclconf/go-cty/cty" + + "github.com/hashicorp/terraform/configs/configschema" + "github.com/hashicorp/terraform/terraform" + "github.com/hashicorp/terraform/helper/copy" ) func setupTest(fixturepath string, args ...string) (*cli.MockUi, int) { ui := new(cli.MockUi) + p := testProvider() + p.GetSchemaReturn = &terraform.ProviderSchema{ + ResourceTypes: map[string]*configschema.Block{ + "test_instance": { + Attributes: map[string]*configschema.Attribute{ + "ami": {Type: cty.String, Optional: true}, + }, + BlockTypes: map[string]*configschema.NestedBlock{ + "network_interface": { + Nesting: configschema.NestingList, + Block: configschema.Block{ + Attributes: map[string]*configschema.Attribute{ + "device_index": {Type: cty.String, Optional: true}, + "description": {Type: cty.String, Optional: true}, + }, + }, + }, + }, + }, + }, + } c := &ValidateCommand{ Meta: Meta{ - testingOverrides: metaOverridesForProvider(testProvider()), + testingOverrides: metaOverridesForProvider(p), Ui: ui, }, }