diff --git a/builtin/providers/digitalocean/resource_digitalocean_ssh_key_test.go b/builtin/providers/digitalocean/resource_digitalocean_ssh_key_test.go index d5c50e6f8d..009366e18a 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_ssh_key_test.go +++ b/builtin/providers/digitalocean/resource_digitalocean_ssh_key_test.go @@ -2,6 +2,8 @@ package digitalocean import ( "fmt" + "strconv" + "strings" "testing" "github.com/hashicorp/terraform/helper/resource" @@ -25,7 +27,7 @@ func TestAccDigitalOceanSSHKey_Basic(t *testing.T) { resource.TestCheckResourceAttr( "digitalocean_ssh_key.foobar", "name", "foobar"), resource.TestCheckResourceAttr( - "digitalocean_ssh_key.foobar", "public_key", "abcdef"), + "digitalocean_ssh_key.foobar", "public_key", testAccValidPublicKey), ), }, }, @@ -82,7 +84,7 @@ func testAccCheckDigitalOceanSSHKeyExists(n string, key *digitalocean.SSHKey) re return err } - if foundKey.Name != rs.Primary.ID { + if strconv.Itoa(int(foundKey.Id)) != rs.Primary.ID { return fmt.Errorf("Record not found") } @@ -92,8 +94,12 @@ func testAccCheckDigitalOceanSSHKeyExists(n string, key *digitalocean.SSHKey) re } } -const testAccCheckDigitalOceanSSHKeyConfig_basic = ` +var testAccCheckDigitalOceanSSHKeyConfig_basic = fmt.Sprintf(` resource "digitalocean_ssh_key" "foobar" { name = "foobar" - public_key = "abcdef" -}` + public_key = "%s" +}`, testAccValidPublicKey) + +var testAccValidPublicKey = strings.TrimSpace(` +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR +`)