github.com/tomaszheflik/terraform@v0.7.3-0.20160827060421-32f990b41594/terraform/transform_output_test.go (about) 1 package terraform 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestAddOutputOrphanTransformer(t *testing.T) { 9 mod := testModule(t, "transform-orphan-output-basic") 10 state := &State{ 11 Modules: []*ModuleState{ 12 &ModuleState{ 13 Path: RootModulePath, 14 Outputs: map[string]*OutputState{ 15 "foo": &OutputState{ 16 Value: "bar", 17 Type: "string", 18 }, 19 "bar": &OutputState{ 20 Value: "baz", 21 Type: "string", 22 }, 23 }, 24 }, 25 }, 26 } 27 28 g := Graph{Path: RootModulePath} 29 { 30 tf := &ConfigTransformer{Module: mod} 31 if err := tf.Transform(&g); err != nil { 32 t.Fatalf("err: %s", err) 33 } 34 } 35 36 transform := &AddOutputOrphanTransformer{State: state} 37 if err := transform.Transform(&g); err != nil { 38 t.Fatalf("err: %s", err) 39 } 40 41 actual := strings.TrimSpace(g.String()) 42 expected := strings.TrimSpace(testTransformOrphanOutputBasicStr) 43 if actual != expected { 44 t.Fatalf("bad:\n\n%s", actual) 45 } 46 } 47 48 const testTransformOrphanOutputBasicStr = ` 49 output.bar (orphan) 50 output.foo 51 `