github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/aws/resource_aws_spot_fleet_request_migrate_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/terraform/terraform"
     7  )
     8  
     9  func TestAWSSpotFleetRequestMigrateState(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  				"associate_public_ip_address": "true",
    22  			},
    23  			Expected: "false",
    24  		},
    25  	}
    26  
    27  	for tn, tc := range cases {
    28  		is := &terraform.InstanceState{
    29  			ID:         tc.ID,
    30  			Attributes: tc.Attributes,
    31  		}
    32  		is, err := resourceAwsSpotFleetRequestMigrateState(
    33  			tc.StateVersion, is, tc.Meta)
    34  
    35  		if err != nil {
    36  			t.Fatalf("bad: %s, err: %#v", tn, err)
    37  		}
    38  
    39  		if is.Attributes["associate_public_ip_address"] != tc.Expected {
    40  			t.Fatalf("bad Spot Fleet Request Migrate: %s\n\n expected: %s", is.Attributes["associate_public_ip_address"], tc.Expected)
    41  		}
    42  	}
    43  }