provider/docker: Fix flaky integration tests
Asserting on the value of `latest` on an image is prone to failing because of new images being pushed upstream. Instead of asserting on a hash, we assert that the value matches a regular expression for the format of an image hash.
This commit is contained in:
parent
ee7553f076
commit
65b071d1af
|
@ -1,6 +1,7 @@
|
|||
package docker
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
|
@ -14,17 +15,14 @@ func TestAccDockerImage_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAccDockerImageConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
"docker_image.foo",
|
||||
"latest",
|
||||
"8dd8107abd2e22bfd3b45b05733f3d2677d4078b09b5edce56ee3d8677d3c648"),
|
||||
resource.TestMatchResourceAttr("docker_image.foo", "latest", regexp.MustCompile(`\A[a-f0-9]{64}\z`)),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAddDockerImage_private(t *testing.T) {
|
||||
func TestAccDockerImage_private(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -32,10 +30,7 @@ func TestAddDockerImage_private(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: testAddDockerPrivateImageConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
"docker_image.foobar",
|
||||
"latest",
|
||||
"2c40b0526b6358710fd09e7b8c022429268cc61703b4777e528ac9d469a07ca1"),
|
||||
resource.TestMatchResourceAttr("docker_image.foobar", "latest", regexp.MustCompile(`\A[a-f0-9]{64}\z`)),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue