diff --git a/builtin/providers/digitalocean/resource_digitalocean_droplet_test.go b/builtin/providers/digitalocean/resource_digitalocean_droplet_test.go index 7f85034cb..d3a37a82c 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_droplet_test.go +++ b/builtin/providers/digitalocean/resource_digitalocean_droplet_test.go @@ -72,7 +72,7 @@ func TestAccDigitalOceanDroplet_Update(t *testing.T) { } func TestAccDigitalOceanDroplet_UpdateUserData(t *testing.T) { - var droplet godo.Droplet + var afterCreate, afterUpdate godo.Droplet resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -82,19 +82,21 @@ func TestAccDigitalOceanDroplet_UpdateUserData(t *testing.T) { resource.TestStep{ Config: testAccCheckDigitalOceanDropletConfig_basic, Check: resource.ComposeTestCheckFunc( - testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet), - testAccCheckDigitalOceanDropletAttributes(&droplet), + testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterCreate), + testAccCheckDigitalOceanDropletAttributes(&afterCreate), ), }, resource.TestStep{ Config: testAccCheckDigitalOceanDropletConfig_userdata_update, Check: resource.ComposeTestCheckFunc( - testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet), + testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterUpdate), resource.TestCheckResourceAttr( "digitalocean_droplet.foobar", "user_data", "foobar foobar"), + testAccCheckDigitalOceanDropletRecreated( + t, &afterCreate, &afterUpdate), ), }, }, @@ -263,6 +265,16 @@ func testAccCheckDigitalOceanDropletExists(n string, droplet *godo.Droplet) reso } } +func testAccCheckDigitalOceanDropletRecreated(t *testing.T, + before, after *godo.Droplet) resource.TestCheckFunc { + return func(s *terraform.State) error { + if before.ID == after.ID { + t.Fatalf("Expected change of droplet IDs, but both were %v", before.ID) + } + return nil + } +} + // Not sure if this check should remain here as the underlaying // function is changed and is tested indirectly by almost all // other test already