forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_source_aws_api_gateway_api_key_test.go
42 lines (36 loc) · 1.14 KB
/
data_source_aws_api_gateway_api_key_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package aws
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDataSourceAwsApiGatewayApiKey(t *testing.T) {
rName := acctest.RandString(8)
resourceName1 := "aws_api_gateway_api_key.example_key"
dataSourceName1 := "data.aws_api_gateway_api_key.test_key"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAwsApiGatewayApiKeyConfig(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(resourceName1, "id", dataSourceName1, "id"),
resource.TestCheckResourceAttrPair(resourceName1, "name", dataSourceName1, "name"),
resource.TestCheckResourceAttrPair(resourceName1, "value", dataSourceName1, "value"),
),
},
},
})
}
func testAccDataSourceAwsApiGatewayApiKeyConfig(r string) string {
return fmt.Sprintf(`
resource "aws_api_gateway_api_key" "example_key" {
name = "%s"
}
data "aws_api_gateway_api_key" "test_key" {
id = "${aws_api_gateway_api_key.example_key.id}"
}
`, r)
}