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

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  	"regexp"
     6  	"testing"
     7  
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestAccAwsAcmCertificateDataSource_noMatchReturnsError(t *testing.T) {
    12  	domain := "hashicorp.com"
    13  	resource.Test(t, resource.TestCase{
    14  		PreCheck: func() {
    15  			testAccPreCheck(t)
    16  		},
    17  		Providers: testAccProviders,
    18  		Steps: []resource.TestStep{
    19  			{
    20  				Config:      testAccCheckAwsAcmCertificateDataSourceConfig(domain),
    21  				ExpectError: regexp.MustCompile(`No certificate for domain`),
    22  			},
    23  			{
    24  				Config:      testAccCheckAwsAcmCertificateDataSourceConfigWithStatus(domain),
    25  				ExpectError: regexp.MustCompile(`No certificate for domain`),
    26  			},
    27  		},
    28  	})
    29  }
    30  
    31  func testAccCheckAwsAcmCertificateDataSourceConfig(domain string) string {
    32  	return fmt.Sprintf(`
    33  data "aws_acm_certificate" "test" {
    34  	domain = "%s"
    35  }
    36  `, domain)
    37  }
    38  
    39  func testAccCheckAwsAcmCertificateDataSourceConfigWithStatus(domain string) string {
    40  	return fmt.Sprintf(`
    41  data "aws_acm_certificate" "test" {
    42  	domain = "%s"
    43  	statuses = ["ISSUED"]
    44  }
    45  `, domain)
    46  }