Skip to content

Commit 97bae0e

Browse files
committed
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.
1 parent 316d473 commit 97bae0e

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

builtin/providers/heroku/resource_heroku_cert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func resourceHerokuCertCreate(d *schema.ResourceData, meta interface{}) error {
5858
log.Printf("[DEBUG] SSL Certificate create configuration: %#v, %#v", app, opts)
5959
a, err := client.SSLEndpointCreate(app, opts)
6060
if err != nil {
61-
panic(err)
61+
return fmt.Errorf("Error creating SSL endpoint: %s", err)
6262
}
6363

6464
d.SetId(a.ID)

builtin/providers/heroku/resource_heroku_cert_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/cyberdelia/heroku-go/v3"
10+
"github.com/hashicorp/terraform/helper/acctest"
1011
"github.com/hashicorp/terraform/helper/resource"
1112
"github.com/hashicorp/terraform/terraform"
1213
)
@@ -17,9 +18,10 @@ func TestAccHerokuCert_Basic(t *testing.T) {
1718
certificateChainFile := wd + "/test-fixtures/terraform.cert"
1819
certificateChainBytes, _ := ioutil.ReadFile(certificateChainFile)
1920
certificateChain := string(certificateChainBytes)
21+
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
2022
testAccCheckHerokuCertConfig_basic := `
2123
resource "heroku_app" "foobar" {
22-
name = "terraform-test-cert-app"
24+
name = "` + appName + `"
2325
region = "eu"
2426
}
2527
@@ -47,7 +49,8 @@ func TestAccHerokuCert_Basic(t *testing.T) {
4749
testAccCheckHerokuCertExists("heroku_cert.ssl_certificate", &endpoint),
4850
testAccCheckHerokuCertificateChain(&endpoint, certificateChain),
4951
resource.TestCheckResourceAttr(
50-
"heroku_cert.ssl_certificate", "cname", "terraform-test-cert-app.herokuapp.com"),
52+
"heroku_cert.ssl_certificate",
53+
"cname", fmt.Sprintf("%s.herokuapp.com", appName)),
5154
),
5255
},
5356
},

0 commit comments

Comments
 (0)