github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/builtin/providers/aws/resource_aws_subnet_migrate_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/terraform/terraform"
     7  )
     8  
     9  func TestAWSSubnetMigrateState(t *testing.T) {
    10  	cases := map[string]struct {
    11  		StateVersion int
    12  		ID           string
    13  		Attributes   map[string]string
    14  		Expected     string
    15  		Meta         interface{}
    16  	}{
    17  		"v0_1_without_value": {
    18  			StateVersion: 0,
    19  			ID:           "some_id",
    20  			Attributes:   map[string]string{},
    21  			Expected:     "false",
    22  		},
    23  	}
    24  
    25  	for tn, tc := range cases {
    26  		is := &terraform.InstanceState{
    27  			ID:         tc.ID,
    28  			Attributes: tc.Attributes,
    29  		}
    30  		is, err := resourceAwsSubnetMigrateState(
    31  			tc.StateVersion, is, tc.Meta)
    32  
    33  		if err != nil {
    34  			t.Fatalf("bad: %s, err: %#v", tn, err)
    35  		}
    36  
    37  		if is.Attributes["assign_ipv6_address_on_creation"] != tc.Expected {
    38  			t.Fatalf("bad Subnet Migrate: %s\n\n expected: %s", is.Attributes["assign_ipv6_address_on_creation"], tc.Expected)
    39  		}
    40  	}
    41  }