terraform-provider-google/google/data_source_container_registry_test.go
Nathan McKinley d8aea17b19
New simple data sources for GCR Repo and Image. (#954)
New, very simple data sources for GCR Repo and Image, plus docs.
2018-01-17 18:47:25 -08:00

79 lines
2.0 KiB
Go

package google
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestDataSourceGoogleContainerRegistryRepository(t *testing.T) {
t.Parallel()
resourceName := "data.google_container_registry_repository.default"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckGoogleContainerRegistryRepo_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(resourceName, "project"),
resource.TestCheckResourceAttrSet(resourceName, "region"),
resource.TestCheckResourceAttr(resourceName, "repository_url", "bar.gcr.io/foo"),
),
},
},
})
}
const testAccCheckGoogleContainerRegistryRepo_basic = `
data "google_container_registry_repository" "default" {
project = "foo"
region = "bar"
}
`
func TestDataSourceGoogleContainerRegistryImage(t *testing.T) {
t.Parallel()
resourceName := "data.google_container_registry_image.test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckGoogleContainerRegistryImage_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(resourceName, "project"),
resource.TestCheckResourceAttrSet(resourceName, "region"),
resource.TestCheckResourceAttr(resourceName, "image_url", "bar.gcr.io/foo/baz"),
resource.TestCheckResourceAttr(resourceName+"2", "image_url", "bar.gcr.io/foo/baz:qux"),
resource.TestCheckResourceAttr(resourceName+"3", "image_url", "bar.gcr.io/foo/baz@1234"),
),
},
},
})
}
const testAccCheckGoogleContainerRegistryImage_basic = `
data "google_container_registry_image" "test" {
project = "foo"
region = "bar"
name = "baz"
}
data "google_container_registry_image" "test2" {
project = "foo"
region = "bar"
name = "baz"
tag = "qux"
}
data "google_container_registry_image" "test3" {
project = "foo"
region = "bar"
name = "baz"
digest = "1234"
}
`