github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/docker/data_source_docker_registry_image_test.go (about) 1 package docker 2 3 import ( 4 "regexp" 5 "testing" 6 7 "github.com/hashicorp/terraform/helper/resource" 8 ) 9 10 var registryDigestRegexp = regexp.MustCompile(`\A[A-Za-z0-9_\+\.-]+:[A-Fa-f0-9]+\z`) 11 12 func TestAccDockerRegistryImage_basic(t *testing.T) { 13 resource.Test(t, resource.TestCase{ 14 PreCheck: func() { testAccPreCheck(t) }, 15 Providers: testAccProviders, 16 Steps: []resource.TestStep{ 17 resource.TestStep{ 18 Config: testAccDockerImageDataSourceConfig, 19 Check: resource.ComposeTestCheckFunc( 20 resource.TestMatchResourceAttr("data.docker_registry_image.foo", "sha256_digest", registryDigestRegexp), 21 ), 22 }, 23 }, 24 }) 25 } 26 27 func TestAccDockerRegistryImage_private(t *testing.T) { 28 resource.Test(t, resource.TestCase{ 29 PreCheck: func() { testAccPreCheck(t) }, 30 Providers: testAccProviders, 31 Steps: []resource.TestStep{ 32 resource.TestStep{ 33 Config: testAccDockerImageDataSourcePrivateConfig, 34 Check: resource.ComposeTestCheckFunc( 35 resource.TestMatchResourceAttr("data.docker_registry_image.bar", "sha256_digest", registryDigestRegexp), 36 ), 37 }, 38 }, 39 }) 40 } 41 42 const testAccDockerImageDataSourceConfig = ` 43 data "docker_registry_image" "foo" { 44 name = "alpine:latest" 45 } 46 ` 47 48 const testAccDockerImageDataSourcePrivateConfig = ` 49 data "docker_registry_image" "bar" { 50 name = "gcr.io:443/google_containers/pause:0.8.0" 51 } 52 `