providers/digitalocean: fix ssh key test

there's now validation on the public key field
This commit is contained in:
Paul Hinze 2015-04-02 09:04:59 -05:00
parent 854267fb0e
commit ace47c1c5b
1 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,8 @@ package digitalocean
import ( import (
"fmt" "fmt"
"strconv"
"strings"
"testing" "testing"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
@ -25,7 +27,7 @@ func TestAccDigitalOceanSSHKey_Basic(t *testing.T) {
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"digitalocean_ssh_key.foobar", "name", "foobar"), "digitalocean_ssh_key.foobar", "name", "foobar"),
resource.TestCheckResourceAttr( 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 return err
} }
if foundKey.Name != rs.Primary.ID { if strconv.Itoa(int(foundKey.Id)) != rs.Primary.ID {
return fmt.Errorf("Record not found") 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" { resource "digitalocean_ssh_key" "foobar" {
name = "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
`)