github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/data_source_aws_iam_account_alias_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/terraform/helper/resource"
     8  	"github.com/hashicorp/terraform/terraform"
     9  )
    10  
    11  func TestAccAWSIamAccountAlias_basic(t *testing.T) {
    12  	resource.Test(t, resource.TestCase{
    13  		PreCheck:  func() { testAccPreCheck(t) },
    14  		Providers: testAccProviders,
    15  		Steps: []resource.TestStep{
    16  			{
    17  				Config: testAccCheckAwsIamAccountAliasConfig_basic,
    18  				Check: resource.ComposeTestCheckFunc(
    19  					testAccCheckAwsIamAccountAlias("data.aws_iam_account_alias.current"),
    20  				),
    21  			},
    22  		},
    23  	})
    24  }
    25  
    26  func testAccCheckAwsIamAccountAlias(n string) resource.TestCheckFunc {
    27  	return func(s *terraform.State) error {
    28  		rs, ok := s.RootModule().Resources[n]
    29  		if !ok {
    30  			return fmt.Errorf("Can't find Account Alias resource: %s", n)
    31  		}
    32  
    33  		if rs.Primary.Attributes["account_alias"] == "" {
    34  			return fmt.Errorf("Missing Account Alias")
    35  		}
    36  
    37  		return nil
    38  	}
    39  }
    40  
    41  const testAccCheckAwsIamAccountAliasConfig_basic = `
    42  data "aws_iam_account_alias" "current" { }
    43  `