github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/resource_aws_cloudwatch_metric_alarm_migrate_test.go (about) 1 package aws 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/terraform/terraform" 7 ) 8 9 func TestAWSCloudWatchMetricAlarmMigrateState(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 Expected: "missing", 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 := resourceAwsCloudWatchMetricAlarmMigrateState( 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["treat_missing_data"] != tc.Expected { 38 t.Fatalf("bad Cloudwatch Metric Alarm Migrate: %s\n\n expected: %s", is.Attributes["treat_missing_data"], tc.Expected) 39 } 40 } 41 }