From 3999cc262e9febdaea55f53e0f0293c444464243 Mon Sep 17 00:00:00 2001 From: T-jegou Date: Fri, 10 Nov 2023 14:29:50 +0100 Subject: [PATCH] Acceptance testing for the region_slug process with uppercase characters. --- digitalocean/volume/resource_volume_test.go | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/digitalocean/volume/resource_volume_test.go b/digitalocean/volume/resource_volume_test.go index 7fefead46..581ada099 100644 --- a/digitalocean/volume/resource_volume_test.go +++ b/digitalocean/volume/resource_volume_test.go @@ -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"] +}`