mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
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
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
@ -14,17 +15,14 @@ func TestAccDockerImage_basic(t *testing.T) {
|
|||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccDockerImageConfig,
|
Config: testAccDockerImageConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestMatchResourceAttr("docker_image.foo", "latest", regexp.MustCompile(`\A[a-f0-9]{64}\z`)),
|
||||||
"docker_image.foo",
|
|
||||||
"latest",
|
|
||||||
"8dd8107abd2e22bfd3b45b05733f3d2677d4078b09b5edce56ee3d8677d3c648"),
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAddDockerImage_private(t *testing.T) {
|
func TestAccDockerImage_private(t *testing.T) {
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
@ -32,10 +30,7 @@ func TestAddDockerImage_private(t *testing.T) {
|
|||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAddDockerPrivateImageConfig,
|
Config: testAddDockerPrivateImageConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestMatchResourceAttr("docker_image.foobar", "latest", regexp.MustCompile(`\A[a-f0-9]{64}\z`)),
|
||||||
"docker_image.foobar",
|
|
||||||
"latest",
|
|
||||||
"2c40b0526b6358710fd09e7b8c022429268cc61703b4777e528ac9d469a07ca1"),
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user