cli: format/state_test.go

Added a very simple test with state and schema.
TODO: if tests are added we should test using golden files (and example
state files, instead of strings). This seemed unnecessary with the
simple test cases.
This commit is contained in:
Kristin Laemmert 2018-09-26 10:11:18 -07:00 committed by Martin Atkins
parent 14c28b8de4
commit d08fe7a91f
2 changed files with 13 additions and 3 deletions

View File

@ -59,7 +59,7 @@ func State(opts *StateOpts) string {
if m.OutputValues != nil {
if len(m.OutputValues) > 0 {
p.buf.WriteString("\nOutputs:\n\n")
p.buf.WriteString("Outputs:\n\n")
}
// Sort the outputs

View File

@ -61,7 +61,7 @@ func TestState(t *testing.T) {
Color: disabledColorize,
Schemas: testSchemas(),
},
"test_resource.baz",
TestOutput,
},
}
@ -69,7 +69,7 @@ func TestState(t *testing.T) {
got := State(tt.State)
if got != tt.Want {
t.Errorf(
"wrong result\ninput: %v\ngot: %s\nwant: %s",
"wrong result\ninput: %v\ngot: \n%s\nwant: \n%s",
tt.State.State, got, tt.Want,
)
}
@ -122,3 +122,13 @@ func testSchemas() *terraform.Schemas {
},
}
}
const TestOutput = `# test_resource.baz[0]:
resource "test_resource" "baz" {
woozles = "confuzles"
}
Outputs:
bar = "bar value"`