From d08fe7a91fd08491937a130f4ed2f72728b76b61 Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Wed, 26 Sep 2018 10:11:18 -0700 Subject: [PATCH] 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. --- command/format/state.go | 2 +- command/format/state_test.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/command/format/state.go b/command/format/state.go index 6b3bd378f3..68b5432dc6 100644 --- a/command/format/state.go +++ b/command/format/state.go @@ -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 diff --git a/command/format/state_test.go b/command/format/state_test.go index 7da016cb63..3c946d37ad 100644 --- a/command/format/state_test.go +++ b/command/format/state_test.go @@ -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"`