github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/terraform/transform_root_test.go (about) 1 package terraform 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestRootTransformer(t *testing.T) { 9 mod := testModule(t, "transform-root-basic") 10 11 g := Graph{Path: RootModulePath} 12 { 13 tf := &ConfigTransformer{Module: mod} 14 if err := tf.Transform(&g); err != nil { 15 t.Fatalf("err: %s", err) 16 } 17 } 18 19 { 20 transform := &ProviderTransformer{} 21 if err := transform.Transform(&g); err != nil { 22 t.Fatalf("err: %s", err) 23 } 24 } 25 26 { 27 transform := &RootTransformer{} 28 if err := transform.Transform(&g); err != nil { 29 t.Fatalf("err: %s", err) 30 } 31 } 32 33 actual := strings.TrimSpace(g.String()) 34 expected := strings.TrimSpace(testTransformRootBasicStr) 35 if actual != expected { 36 t.Fatalf("bad:\n\n%s", actual) 37 } 38 39 root, err := g.Root() 40 if err != nil { 41 t.Fatalf("err: %s", err) 42 } 43 if _, ok := root.(graphNodeRoot); !ok { 44 t.Fatalf("bad: %#v", root) 45 } 46 } 47 48 const testTransformRootBasicStr = ` 49 aws_instance.foo 50 provider.aws 51 do_droplet.bar 52 provider.do 53 provider.aws 54 provider.do 55 root 56 aws_instance.foo 57 do_droplet.bar 58 `