github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/data_source_aws_partition_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 TestAccAWSPartition_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: testAccCheckAwsPartitionConfig_basic, 18 Check: resource.ComposeTestCheckFunc( 19 testAccCheckAwsPartition("data.aws_partition.current"), 20 ), 21 }, 22 }, 23 }) 24 } 25 26 func testAccCheckAwsPartition(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 resource: %s", n) 31 } 32 33 expected := testAccProvider.Meta().(*AWSClient).partition 34 if rs.Primary.Attributes["partition"] != expected { 35 return fmt.Errorf("Incorrect Partition: expected %q, got %q", expected, rs.Primary.Attributes["partition"]) 36 } 37 38 return nil 39 } 40 } 41 42 const testAccCheckAwsPartitionConfig_basic = ` 43 data "aws_partition" "current" { } 44 `