fix show-json test to expect error from nested mod

One of the show json command tests expected no error when presented with
an invalid configuration in a nested module. Modify the test created in
PR #21569 so that it can still verify there is no panic, but now expect
an error from init.
This commit is contained in:
James Bardin 2019-07-16 21:25:30 -04:00
parent 8111050c66
commit e4640a43d7
6 changed files with 45 additions and 20 deletions

View File

@ -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)
}

View File

@ -0,0 +1,3 @@
module "my_module" {
source = "./modules"
}

View File

@ -0,0 +1,3 @@
module "more" {
source = "./more-modules"
}

View File

@ -0,0 +1,4 @@
variable "misspelled" {
default = "ehllo"
descriptoni = "I am a misspelled attribute"
}

View File

@ -1,4 +1,4 @@
variable "misspelled" {
default = "ehllo"
descriptoni = "I am a misspelled attribute"
variable "ok" {
default = "something"
description = "description"
}

View File

@ -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"
}
}
}
}
}
}
}
}
}