provider/heroku: address cert test failure

* Randomize app name in test
 * Return error and don't panic when there is a problem

It's possible there may still be an underlying problem that caused the
error that made the cert leak in the first place - this should help us
diagnose it.
This commit is contained in:
Paul Hinze 2016-02-04 09:57:44 -06:00
parent 316d4734ee
commit 97bae0ea30
2 changed files with 6 additions and 3 deletions

View File

@ -58,7 +58,7 @@ func resourceHerokuCertCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] SSL Certificate create configuration: %#v, %#v", app, opts)
a, err := client.SSLEndpointCreate(app, opts)
if err != nil {
panic(err)
return fmt.Errorf("Error creating SSL endpoint: %s", err)
}
d.SetId(a.ID)

View File

@ -7,6 +7,7 @@ import (
"testing"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -17,9 +18,10 @@ func TestAccHerokuCert_Basic(t *testing.T) {
certificateChainFile := wd + "/test-fixtures/terraform.cert"
certificateChainBytes, _ := ioutil.ReadFile(certificateChainFile)
certificateChain := string(certificateChainBytes)
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
testAccCheckHerokuCertConfig_basic := `
resource "heroku_app" "foobar" {
name = "terraform-test-cert-app"
name = "` + appName + `"
region = "eu"
}
@ -47,7 +49,8 @@ func TestAccHerokuCert_Basic(t *testing.T) {
testAccCheckHerokuCertExists("heroku_cert.ssl_certificate", &endpoint),
testAccCheckHerokuCertificateChain(&endpoint, certificateChain),
resource.TestCheckResourceAttr(
"heroku_cert.ssl_certificate", "cname", "terraform-test-cert-app.herokuapp.com"),
"heroku_cert.ssl_certificate",
"cname", fmt.Sprintf("%s.herokuapp.com", appName)),
),
},
},