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) {
|
func TestAccDigitalOceanDroplet_UpdateUserData(t *testing.T) {
|
||||||
var droplet godo.Droplet
|
var afterCreate, afterUpdate godo.Droplet
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -82,19 +82,21 @@ func TestAccDigitalOceanDroplet_UpdateUserData(t *testing.T) {
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccCheckDigitalOceanDropletConfig_basic,
|
Config: testAccCheckDigitalOceanDropletConfig_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterCreate),
|
||||||
testAccCheckDigitalOceanDropletAttributes(&droplet),
|
testAccCheckDigitalOceanDropletAttributes(&afterCreate),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccCheckDigitalOceanDropletConfig_userdata_update,
|
Config: testAccCheckDigitalOceanDropletConfig_userdata_update,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &droplet),
|
testAccCheckDigitalOceanDropletExists("digitalocean_droplet.foobar", &afterUpdate),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"digitalocean_droplet.foobar",
|
"digitalocean_droplet.foobar",
|
||||||
"user_data",
|
"user_data",
|
||||||
"foobar foobar"),
|
"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
|
// Not sure if this check should remain here as the underlaying
|
||||||
// function is changed and is tested indirectly by almost all
|
// function is changed and is tested indirectly by almost all
|
||||||
// other test already
|
// other test already
|
||||||
|
|
Loading…
Reference in New Issue