Skip to content

Commit

Permalink
Acceptance testing for the region_slug process with uppercase charact…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
T-jegou committed Nov 10, 2023
1 parent ed1da3c commit 3999cc2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions digitalocean/volume/resource_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,47 @@ resource "digitalocean_volume" "foobar" {
description = "peace makes plenty"
tags = ["foo", "bar", "baz"]
}`

func TestAccDigitalOceanVolume_createWithRegionSlugUpperCase(t *testing.T) {
name := acceptance.RandomTestName("volume")

expectedURNRegEx, _ := regexp.Compile(`do:volume:[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}`)

volume := godo.Volume{
Name: name,
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheck(t) },
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: testAccCheckDigitalOceanVolumeDestroy,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccCheckDigitalOceanVolumeConfig_createWithRegionSlugUpperCase, name),
Check: resource.ComposeTestCheckFunc(
testAccCheckDigitalOceanVolumeExists("digitalocean_volume.foobar", &volume),
resource.TestCheckResourceAttr(
"digitalocean_volume.foobar", "name", name),
resource.TestCheckResourceAttr(
"digitalocean_volume.foobar", "size", "100"),
resource.TestCheckResourceAttr(
"digitalocean_volume.foobar", "region", "nyc3"),
resource.TestCheckResourceAttr(
"digitalocean_volume.foobar", "description", "peace makes plenty"),
resource.TestCheckResourceAttr(
"digitalocean_volume.foobar", "tags.#", "2"),
resource.TestMatchResourceAttr("digitalocean_volume.foobar", "urn", expectedURNRegEx),
),
},
},
})
}

const testAccCheckDigitalOceanVolumeConfig_createWithRegionSlugUpperCase = `
resource "digitalocean_volume" "foobar" {
region = "NYC3"
name = "%s"
size = 100
description = "peace makes plenty"
tags = ["foo", "bar"]
}`

0 comments on commit 3999cc2

Please sign in to comment.