Skip to content

Commit

Permalink
Use separate object for "update" test.
Browse files Browse the repository at this point in the history
Assertion was happening against object with initial values.
  • Loading branch information
denys-octopus committed Oct 20, 2024
1 parent 23eeba2 commit d16434f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions octopusdeploy_framework/resource_oci_registry_feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,31 @@ type ociRegistryFeedTestData struct {
func TestAccOctopusDeployOCIRegistryFeed(t *testing.T) {
localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
prefix := "octopusdeploy_oci_registry_feed." + localName
data := ociRegistryFeedTestData{
createData := ociRegistryFeedTestData{
name: acctest.RandStringFromCharSet(20, acctest.CharSetAlpha),
uri: "oci://integration-test-registry.docker.io",
username: acctest.RandStringFromCharSet(20, acctest.CharSetAlpha),
password: acctest.RandStringFromCharSet(20, acctest.CharSetAlphaNum),
}
updateData := ociRegistryFeedTestData{
name: createData.name + "-updated",
uri: "oci://integration-test-registry-updated.docker.io",
username: createData.username + "-changed",
password: createData.password + "-generated",
}

resource.Test(t, resource.TestCase{
CheckDestroy: func(s *terraform.State) error { return testOCIRegistryFeedCheckDestroy(s) },
PreCheck: func() { TestAccPreCheck(t) },
ProtoV6ProviderFactories: ProtoV6ProviderFactories(),
Steps: []resource.TestStep{
{
Config: testOCIRegistryFeedBasic(data, localName),
Check: testAssertOCIRegistryAttributes(data, prefix),
Config: testOCIRegistryFeedBasic(createData, localName),
Check: testAssertOCIRegistryAttributes(createData, prefix),
},
{
Config: testOCIRegistryFeedBasicUpdate(data, localName),
Check: testAssertOCIRegistryAttributes(data, prefix),
Config: testOCIRegistryFeedBasic(updateData, localName),
Check: testAssertOCIRegistryAttributes(updateData, prefix),
},
},
})
Expand Down Expand Up @@ -69,15 +75,6 @@ func testOCIRegistryFeedBasic(data ociRegistryFeedTestData, localName string) st
)
}

func testOCIRegistryFeedBasicUpdate(data ociRegistryFeedTestData, localName string) string {
data.name = data.name + "-updated"
data.uri = "oci://integration-test-registry-updated.docker.io"
data.username = data.username + "-changed"
data.password = data.password + "-generated"

return testOCIRegistryFeedBasic(data, localName)
}

func testOCIRegistryFeedCheckDestroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
if rs.Type != "octopusdeploy_oci_registry_feed" {
Expand Down

0 comments on commit d16434f

Please sign in to comment.