diff --git a/command/show_test.go b/command/show_test.go index 3c2cca3b6..b66a17168 100644 --- a/command/show_test.go +++ b/command/show_test.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strings" "testing" "github.com/google/go-cmp/cmp" @@ -153,6 +154,8 @@ func TestShow_json_output(t *testing.T) { defer os.RemoveAll(td) defer testChdir(t, td)() + expectError := strings.Contains(entry.Name(), "error") + p := showFixtureProvider() ui := new(cli.MockUi) m := Meta{ @@ -171,6 +174,10 @@ func TestShow_json_output(t *testing.T) { }, } if code := ic.Run([]string{}); code != 0 { + if expectError { + // this should error, but not panic. + return + } t.Fatalf("init failed\n%s", ui.ErrorWriter) } diff --git a/command/testdata/show-json/nested-module-error/main.tf b/command/testdata/show-json/nested-module-error/main.tf new file mode 100644 index 000000000..ef0bad2bb --- /dev/null +++ b/command/testdata/show-json/nested-module-error/main.tf @@ -0,0 +1,3 @@ +module "my_module" { + source = "./modules" +} diff --git a/command/testdata/show-json/nested-module-error/modules/main.tf b/command/testdata/show-json/nested-module-error/modules/main.tf new file mode 100644 index 000000000..990155ecb --- /dev/null +++ b/command/testdata/show-json/nested-module-error/modules/main.tf @@ -0,0 +1,3 @@ +module "more" { + source = "./more-modules" +} diff --git a/command/testdata/show-json/nested-module-error/modules/more-modules/main.tf b/command/testdata/show-json/nested-module-error/modules/more-modules/main.tf new file mode 100644 index 000000000..488a27193 --- /dev/null +++ b/command/testdata/show-json/nested-module-error/modules/more-modules/main.tf @@ -0,0 +1,4 @@ +variable "misspelled" { + default = "ehllo" + descriptoni = "I am a misspelled attribute" +} diff --git a/command/testdata/show-json/nested-modules/modules/more-modules/main.tf b/command/testdata/show-json/nested-modules/modules/more-modules/main.tf index 488a27193..7e1ffafe1 100644 --- a/command/testdata/show-json/nested-modules/modules/more-modules/main.tf +++ b/command/testdata/show-json/nested-modules/modules/more-modules/main.tf @@ -1,4 +1,4 @@ -variable "misspelled" { - default = "ehllo" - descriptoni = "I am a misspelled attribute" +variable "ok" { + default = "something" + description = "description" } diff --git a/command/testdata/show-json/nested-modules/output.json b/command/testdata/show-json/nested-modules/output.json index 75f15466e..2dcc54773 100644 --- a/command/testdata/show-json/nested-modules/output.json +++ b/command/testdata/show-json/nested-modules/output.json @@ -1,23 +1,31 @@ { - "format_version": "0.1", - "terraform_version": "0.12.1-dev", - "planned_values": { - "root_module": {} - }, - "configuration": { - "root_module": { + "format_version": "0.1", + "terraform_version": "0.12.1-dev", + "planned_values": { + "root_module": {} + }, + "configuration": { + "root_module": { + "module_calls": { + "my_module": { + "source": "./modules", + "module": { "module_calls": { - "my_module": { - "source": "./modules", - "module": { - "module_calls": { - "more": { - "module": {} - } - } + "more": { + "module": { + "variables": { + "ok": { + "default": "something", + "description": "description" } - } + } + }, + "source": "./more-modules" + } } + } } + } } -} \ No newline at end of file + } +}