github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/terraform/transform_transitive_reduction_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  )
     7  
     8  func TestTransitiveReductionTransformer(t *testing.T) {
     9  	mod := testModule(t, "transform-trans-reduce-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 := &AttachResourceConfigTransformer{Module: mod}
    21  		if err := transform.Transform(&g); err != nil {
    22  			t.Fatalf("err: %s", err)
    23  		}
    24  	}
    25  
    26  	{
    27  		transform := &ReferenceTransformer{}
    28  		if err := transform.Transform(&g); err != nil {
    29  			t.Fatalf("err: %s", err)
    30  		}
    31  	}
    32  
    33  	{
    34  		transform := &TransitiveReductionTransformer{}
    35  		if err := transform.Transform(&g); err != nil {
    36  			t.Fatalf("err: %s", err)
    37  		}
    38  	}
    39  
    40  	actual := strings.TrimSpace(g.String())
    41  	expected := strings.TrimSpace(testTransformTransReduceBasicStr)
    42  	if actual != expected {
    43  		t.Fatalf("bad:\n\n%s", actual)
    44  	}
    45  }
    46  
    47  const testTransformTransReduceBasicStr = `
    48  aws_instance.A
    49  aws_instance.B
    50    aws_instance.A
    51  aws_instance.C
    52    aws_instance.B
    53  `