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:
parent
14c28b8de4
commit
d08fe7a91f
|
@ -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
|
||||
|
|
|
@ -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"`
|
||||
|
|
Loading…
Reference in New Issue