providers/digitalocean: fix acceptance test suite for running

This commit is contained in:
Jack Pearkes 2014-11-02 14:44:32 -08:00
parent 75472ecb8e
commit def922551e
2 changed files with 17 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package digitalocean
import (
"log"
"os"
"github.com/pearkes/digitalocean"
)
@ -14,6 +15,13 @@ type Config struct {
// ocean.
//
func (c *Config) Client() (*digitalocean.Client, error) {
// If we have env vars set (like in the acc) tests,
// we need to override the values passed in here.
if v := os.Getenv("DIGITALOCEAN_TOKEN"); v != "" {
c.Token = v
}
client, err := digitalocean.NewClient(c.Token)
log.Printf("[INFO] DigitalOcean Client configured for URL: %s", client.URL)

View File

@ -25,9 +25,16 @@ func TestResourceProvider_impl(t *testing.T) {
func TestResourceProvider_Configure(t *testing.T) {
rp := new(ResourceProvider)
var expectedToken string
if v := os.Getenv("DIGITALOCEAN_TOKEN"); v != "foo" {
expectedToken = v
} else {
expectedToken = "foo"
}
raw := map[string]interface{}{
"token": "foo",
"token": expectedToken,
}
rawConfig, err := config.NewRawConfig(raw)
@ -41,7 +48,7 @@ func TestResourceProvider_Configure(t *testing.T) {
}
expected := Config{
Token: "foo",
Token: expectedToken,
}
if !reflect.DeepEqual(rp.Config, expected) {