provider/digitalocean: enhance user_data test
Checks to ensure that the droplet is recreated. Commenting out `ForceNew` on `user_data` fails the test now. /cc @stack72
This commit is contained in:
parent
dbaa44a2b4
commit
bf11be82c8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue