Skip to content

Commit

Permalink
provider_test tweak #1 [issues/95-support-for-netrc-authent]
Browse files Browse the repository at this point in the history
  • Loading branch information
davidji99 committed Sep 10, 2018
1 parent a2aba83 commit c4f8188
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions heroku/config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package heroku

import (
"log"
"net/http"

"github.com/hashicorp/terraform/helper/logging"
heroku "github.com/heroku/heroku-go/v3"
"log"
"net/http"
)

type Config struct {
Expand All @@ -16,7 +15,7 @@ type Config struct {
Api *heroku.Service
}

// Client returns a new Service for accessing Heroku.
// Client returns a new Config for accessing Heroku.
func (c *Config) loadAndInitialize() error {
var debugHTTP = false
if logging.IsDebugOrHigher() {
Expand Down
12 changes: 6 additions & 6 deletions heroku/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
h.Set(k, v)
}

// Read from netrc file first. If not available fall back to original authentication
// TODO: do we need to read from netrc during a test run?
err := readNetrcFile(&config, h)
if err != nil {
return nil, err
}

config = Config{
Email: d.Get("email").(string),
APIKey: d.Get("api_key").(string),
Headers: h,
if email, ok := d.GetOk("email"); ok {
config.Email = email.(string)
}

if apiKey, ok := d.GetOk("api_key"); ok {
config.APIKey = apiKey.(string)
}

log.Println("[INFO] Initializing Heroku client")
Expand Down
4 changes: 2 additions & 2 deletions heroku/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func TestProviderConfigureUseNetrc(t *testing.T) {
}
configuration := meta.(*Config)

assert.Equal(t, "email_login", configuration)
//assert.Equal(t, "api_key", configuration.APIKey)
assert.Equal(t, "email_login", configuration.Email)
assert.Equal(t, "api_key", configuration.APIKey)
}

func testAccPreCheck(t *testing.T) {
Expand Down

0 comments on commit c4f8188

Please sign in to comment.