github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/digitalocean/import_digitalocean_ssh_key_test.go (about)

     1  package digitalocean
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/terraform/helper/acctest"
     7  	"github.com/hashicorp/terraform/helper/resource"
     8  )
     9  
    10  func TestAccDigitalOceanSSHKey_importBasic(t *testing.T) {
    11  	resourceName := "digitalocean_ssh_key.foobar"
    12  	rInt := acctest.RandInt()
    13  	publicKeyMaterial, _, err := acctest.RandSSHKeyPair("digitalocean@ssh-acceptance-test")
    14  	if err != nil {
    15  		t.Fatalf("Cannot generate test SSH key pair: %s", err)
    16  	}
    17  
    18  	resource.Test(t, resource.TestCase{
    19  		PreCheck:     func() { testAccPreCheck(t) },
    20  		Providers:    testAccProviders,
    21  		CheckDestroy: testAccCheckDigitalOceanSSHKeyDestroy,
    22  		Steps: []resource.TestStep{
    23  			{
    24  				Config: testAccCheckDigitalOceanSSHKeyConfig_basic(rInt, publicKeyMaterial),
    25  			},
    26  
    27  			{
    28  				ResourceName:      resourceName,
    29  				ImportState:       true,
    30  				ImportStateVerify: true,
    31  			},
    32  		},
    33  	})
    34  }