github.com/skyscape-cloud-services/terraform@v0.9.2-0.20170609144644-7ece028a1747/terraform/transform_config_flat_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  )
     7  
     8  func TestFlatConfigTransformer_nilModule(t *testing.T) {
     9  	g := Graph{Path: RootModulePath}
    10  	tf := &FlatConfigTransformer{}
    11  	if err := tf.Transform(&g); err != nil {
    12  		t.Fatalf("err: %s", err)
    13  	}
    14  
    15  	if len(g.Vertices()) > 0 {
    16  		t.Fatal("graph should be empty")
    17  	}
    18  }
    19  
    20  func TestFlatConfigTransformer(t *testing.T) {
    21  	g := Graph{Path: RootModulePath}
    22  	tf := &FlatConfigTransformer{
    23  		Module: testModule(t, "transform-flat-config-basic"),
    24  	}
    25  	if err := tf.Transform(&g); err != nil {
    26  		t.Fatalf("err: %s", err)
    27  	}
    28  
    29  	actual := strings.TrimSpace(g.String())
    30  	expected := strings.TrimSpace(testTransformFlatConfigBasicStr)
    31  	if actual != expected {
    32  		t.Fatalf("bad:\n\n%s", actual)
    33  	}
    34  }
    35  
    36  const testTransformFlatConfigBasicStr = `
    37  aws_instance.bar
    38  aws_instance.foo
    39  module.child.aws_instance.baz
    40  `