github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/terraform/transform_module_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/dag"
     8  )
     9  
    10  func TestModuleInputTransformer(t *testing.T) {
    11  	var g Graph
    12  	g.Add(1)
    13  	g.Add(2)
    14  	g.Add(3)
    15  	g.Connect(dag.BasicEdge(1, 2))
    16  	g.Connect(dag.BasicEdge(1, 3))
    17  
    18  	{
    19  		tf := &ModuleInputTransformer{}
    20  		if err := tf.Transform(&g); err != nil {
    21  			t.Fatalf("err: %s", err)
    22  		}
    23  	}
    24  
    25  	actual := strings.TrimSpace(g.String())
    26  	expected := strings.TrimSpace(testModuleInputTransformStr)
    27  	if actual != expected {
    28  		t.Fatalf("bad:\n\n%s", actual)
    29  	}
    30  }
    31  
    32  const testModuleInputTransformStr = `
    33  1
    34    2
    35    3
    36  2
    37    module inputs
    38  3
    39    module inputs
    40  module inputs
    41  `