Skip to content

Commit

Permalink
Merge pull request #8706 from terraform-providers/t-xray-PreCheck
Browse files Browse the repository at this point in the history
tests/service/xray: Add PreCheck for service availability
  • Loading branch information
bflad authored May 24, 2019
2 parents 4a829db + 2351aa4 commit 0574520
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions aws/resource_aws_xray_sampling_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccAWSXraySamplingRule_basic(t *testing.T) {
ruleName := fmt.Sprintf("tf_acc_sampling_rule_%s", rString)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSXray(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSXraySamplingRuleDestroy,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestAccAWSXraySamplingRule_update(t *testing.T) {
updatedReservoirSize := acctest.RandIntRange(0, 2147483647)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSXray(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSXraySamplingRuleDestroy,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -152,6 +152,22 @@ func testAccCheckAWSXraySamplingRuleDestroy(s *terraform.State) error {
return nil
}

func testAccPreCheckAWSXray(t *testing.T) {
conn := testAccProvider.Meta().(*AWSClient).xrayconn

input := &xray.GetSamplingRulesInput{}

_, err := conn.GetSamplingRules(input)

if testAccPreCheckSkipError(err) {
t.Skipf("skipping acceptance testing: %s", err)
}

if err != nil {
t.Fatalf("unexpected PreCheck error: %s", err)
}
}

func testAccAWSXraySamplingRuleConfig_basic(ruleName string) string {
return fmt.Sprintf(`
resource "aws_xray_sampling_rule" "test" {
Expand Down

0 comments on commit 0574520

Please sign in to comment.