terraform-provider-google/google/data_source_google_netblock_ip_ranges_test.go
Tenorio Orta JM 6864f1f9e5 Added GCP Netblock Data Source (#1416) (#1580)
* Added GCP Netblock Data Source (#1416)

* Added docs for google_netblock_ip_ranges (#1416)

* Code review changes (#1416)
2018-06-04 16:31:09 -07:00

39 lines
1.3 KiB
Go

package google
import (
"regexp"
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDataSourceGoogleNetblockIpRanges_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccNetblockIpRangesConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.some",
"cidr_blocks.#", regexp.MustCompile(("^[1-9]+[0-9]*$"))),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.some",
"cidr_blocks.0", regexp.MustCompile("^[0-9./:]+$")),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.some",
"cidr_blocks_ipv4.#", regexp.MustCompile(("^[1-9]+[0-9]*$"))),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.some",
"cidr_blocks_ipv4.0", regexp.MustCompile("^[0-9./]+$")),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.some",
"cidr_blocks_ipv6.#", regexp.MustCompile(("^[1-9]+[0-9]*$"))),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.some",
"cidr_blocks_ipv6.0", regexp.MustCompile("^[0-9./:]+$")),
),
},
},
})
}
const testAccNetblockIpRangesConfig = `
data "google_netblock_ip_ranges" "some" {}
`