github.com/federicobaldo/terraform@v0.6.15-0.20160323222747-b20f680cbf05/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]string{ 15 "foo": "bar", 16 "bar": "baz", 17 }, 18 }, 19 }, 20 } 21 22 g := Graph{Path: RootModulePath} 23 { 24 tf := &ConfigTransformer{Module: mod} 25 if err := tf.Transform(&g); err != nil { 26 t.Fatalf("err: %s", err) 27 } 28 } 29 30 transform := &AddOutputOrphanTransformer{State: state} 31 if err := transform.Transform(&g); err != nil { 32 t.Fatalf("err: %s", err) 33 } 34 35 actual := strings.TrimSpace(g.String()) 36 expected := strings.TrimSpace(testTransformOrphanOutputBasicStr) 37 if actual != expected { 38 t.Fatalf("bad:\n\n%s", actual) 39 } 40 } 41 42 const testTransformOrphanOutputBasicStr = ` 43 output.bar (orphan) 44 output.foo 45 `