github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/resource_aws_vpc_migrate_test.go (about) 1 package aws 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform/terraform" 7 ) 8 9 func TestAWSVpcMigrateState(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": { 18 StateVersion: 0, 19 ID: "some_id", 20 Attributes: map[string]string{ 21 "assign_generated_ipv6_cidr_block": "true", 22 }, 23 Expected: "false", 24 }, 25 "v0_1_without_value": { 26 StateVersion: 0, 27 ID: "some_id", 28 Attributes: map[string]string{}, 29 Expected: "false", 30 }, 31 } 32 33 for tn, tc := range cases { 34 is := &terraform.InstanceState{ 35 ID: tc.ID, 36 Attributes: tc.Attributes, 37 } 38 is, err := resourceAwsVpcMigrateState( 39 tc.StateVersion, is, tc.Meta) 40 41 if err != nil { 42 t.Fatalf("bad: %s, err: %#v", tn, err) 43 } 44 45 if is.Attributes["assign_generated_ipv6_cidr_block"] != tc.Expected { 46 t.Fatalf("bad VPC Migrate: %s\n\n expected: %s", is.Attributes["assign_generated_ipv6_cidr_block"], tc.Expected) 47 } 48 } 49 }