github.com/federicobaldo/terraform@v0.6.15-0.20160323222747-b20f680cbf05/terraform/graph_config_node_test.go (about)

     1  package terraform
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/config"
     8  	"github.com/hashicorp/terraform/dag"
     9  )
    10  
    11  func TestGraphNodeConfigOutput_impl(t *testing.T) {
    12  	var _ dag.Vertex = new(GraphNodeConfigOutput)
    13  	var _ dag.NamedVertex = new(GraphNodeConfigOutput)
    14  	var _ graphNodeConfig = new(GraphNodeConfigOutput)
    15  	var _ GraphNodeOutput = new(GraphNodeConfigOutput)
    16  	var _ GraphNodeProxy = new(GraphNodeConfigOutput)
    17  }
    18  
    19  func TestGraphNodeConfigProvider_impl(t *testing.T) {
    20  	var _ dag.Vertex = new(GraphNodeConfigProvider)
    21  	var _ dag.NamedVertex = new(GraphNodeConfigProvider)
    22  	var _ graphNodeConfig = new(GraphNodeConfigProvider)
    23  	var _ GraphNodeProvider = new(GraphNodeConfigProvider)
    24  }
    25  
    26  func TestGraphNodeConfigProvider_ProviderName(t *testing.T) {
    27  	n := &GraphNodeConfigProvider{
    28  		Provider: &config.ProviderConfig{Name: "foo"},
    29  	}
    30  
    31  	if v := n.ProviderName(); v != "foo" {
    32  		t.Fatalf("bad: %#v", v)
    33  	}
    34  }
    35  
    36  func TestGraphNodeConfigProvider_ProviderName_alias(t *testing.T) {
    37  	n := &GraphNodeConfigProvider{
    38  		Provider: &config.ProviderConfig{Name: "foo", Alias: "bar"},
    39  	}
    40  
    41  	if v := n.ProviderName(); v != "foo.bar" {
    42  		t.Fatalf("bad: %#v", v)
    43  	}
    44  }
    45  
    46  func TestGraphNodeConfigProvider_Name(t *testing.T) {
    47  	n := &GraphNodeConfigProvider{
    48  		Provider: &config.ProviderConfig{Name: "foo"},
    49  	}
    50  
    51  	if v := n.Name(); v != "provider.foo" {
    52  		t.Fatalf("bad: %#v", v)
    53  	}
    54  }
    55  
    56  func TestGraphNodeConfigProvider_Name_alias(t *testing.T) {
    57  	n := &GraphNodeConfigProvider{
    58  		Provider: &config.ProviderConfig{Name: "foo", Alias: "bar"},
    59  	}
    60  
    61  	if v := n.Name(); v != "provider.foo.bar" {
    62  		t.Fatalf("bad: %#v", v)
    63  	}
    64  }
    65  
    66  func TestGraphNodeConfigResource_impl(t *testing.T) {
    67  	var _ dag.Vertex = new(GraphNodeConfigResource)
    68  	var _ dag.NamedVertex = new(GraphNodeConfigResource)
    69  	var _ graphNodeConfig = new(GraphNodeConfigResource)
    70  	var _ GraphNodeProviderConsumer = new(GraphNodeConfigResource)
    71  	var _ GraphNodeProvisionerConsumer = new(GraphNodeConfigResource)
    72  }
    73  
    74  func TestGraphNodeConfigResource_ProvidedBy(t *testing.T) {
    75  	n := &GraphNodeConfigResource{
    76  		Resource: &config.Resource{Type: "aws_instance"},
    77  	}
    78  
    79  	if v := n.ProvidedBy(); v[0] != "aws" {
    80  		t.Fatalf("bad: %#v", v)
    81  	}
    82  }
    83  
    84  func TestGraphNodeConfigResource_ProvidedBy_alias(t *testing.T) {
    85  	n := &GraphNodeConfigResource{
    86  		Resource: &config.Resource{Type: "aws_instance", Provider: "aws.bar"},
    87  	}
    88  
    89  	if v := n.ProvidedBy(); v[0] != "aws.bar" {
    90  		t.Fatalf("bad: %#v", v)
    91  	}
    92  }
    93  
    94  func TestGraphNodeConfigResource_ProvisionedBy(t *testing.T) {
    95  	n := &GraphNodeConfigResource{
    96  		Resource: &config.Resource{
    97  			Type: "aws_instance",
    98  			Provisioners: []*config.Provisioner{
    99  				&config.Provisioner{Type: "foo"},
   100  				&config.Provisioner{Type: "bar"},
   101  			},
   102  		},
   103  	}
   104  
   105  	expected := []string{"foo", "bar"}
   106  	actual := n.ProvisionedBy()
   107  	if !reflect.DeepEqual(actual, expected) {
   108  		t.Fatalf("bad: %#v", actual)
   109  	}
   110  }