mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-15 07:27:15 +00:00
d8aea17b19
New, very simple data sources for GCR Repo and Image, plus docs.
79 lines
2.0 KiB
Go
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"
|
|
}
|
|
`
|