provider/digitalocean: Support Import `digitalocean_droplet` (#7344)

```
ake testacc TEST=./builtin/providers/digitalocean
TESTARGS='-run=TestAccDigitalOceanDroplet_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/digitalocean -v -run=TestAccDigitalOceanDroplet_ -timeout 120m
=== RUN   TestAccDigitalOceanDroplet_importBasic
--- PASS: TestAccDigitalOceanDroplet_importBasic (39.42s)
=== RUN   TestAccDigitalOceanDroplet_Basic
--- PASS: TestAccDigitalOceanDroplet_Basic (38.46s)
=== RUN   TestAccDigitalOceanDroplet_Update
--- PASS: TestAccDigitalOceanDroplet_Update (244.82s)
=== RUN   TestAccDigitalOceanDroplet_UpdateUserData
--- PASS: TestAccDigitalOceanDroplet_UpdateUserData (73.05s)
=== RUN   TestAccDigitalOceanDroplet_PrivateNetworkingIpv6
--- PASS: TestAccDigitalOceanDroplet_PrivateNetworkingIpv6 (67.24s)
PASS
```
This commit is contained in:
Paul Stack 2016-06-29 20:28:47 +01:00 committed by GitHub
parent ae21cdef0f
commit e905aa2840
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package digitalocean
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDigitalOceanDroplet_importBasic(t *testing.T) {
resourceName := "digitalocean_droplet.foobar"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDigitalOceanDropletDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckDigitalOceanDropletConfig_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"ssh_keys", "user_data"}, //we ignore the ssh_keys and user_data as we do not set to state
},
},
})
}

View File

@ -18,6 +18,9 @@ func resourceDigitalOceanDroplet() *schema.Resource {
Read: resourceDigitalOceanDropletRead, Read: resourceDigitalOceanDropletRead,
Update: resourceDigitalOceanDropletUpdate, Update: resourceDigitalOceanDropletUpdate,
Delete: resourceDigitalOceanDropletDelete, Delete: resourceDigitalOceanDropletDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"image": &schema.Schema{ "image": &schema.Schema{