github.com/jmbataller/terraform@v0.6.8-0.20151125192640-b7a12e3a580c/terraform/transform_proxy_test.go (about) 1 package terraform 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/hashicorp/terraform/dag" 8 ) 9 10 func TestProxyTransformer(t *testing.T) { 11 var g Graph 12 proxy := &testNodeProxy{NameValue: "proxy"} 13 g.Add("A") 14 g.Add("C") 15 g.Add(proxy) 16 g.Connect(dag.BasicEdge("A", proxy)) 17 g.Connect(dag.BasicEdge(proxy, "C")) 18 19 { 20 tf := &ProxyTransformer{} 21 if err := tf.Transform(&g); err != nil { 22 t.Fatalf("err: %s", err) 23 } 24 } 25 26 actual := strings.TrimSpace(g.String()) 27 expected := strings.TrimSpace(testProxyTransformStr) 28 if actual != expected { 29 t.Fatalf("bad: %s", actual) 30 } 31 } 32 33 type testNodeProxy struct { 34 NameValue string 35 } 36 37 func (n *testNodeProxy) Name() string { 38 return n.NameValue 39 } 40 41 func (n *testNodeProxy) Proxy() bool { 42 return true 43 } 44 45 const testProxyTransformStr = ` 46 A 47 C 48 proxy 49 C 50 proxy 51 C 52 `