providers/digitalocean: fix acceptance test suite for running
This commit is contained in:
parent
75472ecb8e
commit
def922551e
|
@ -2,6 +2,7 @@ package digitalocean
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/pearkes/digitalocean"
|
"github.com/pearkes/digitalocean"
|
||||||
)
|
)
|
||||||
|
@ -14,6 +15,13 @@ type Config struct {
|
||||||
// ocean.
|
// ocean.
|
||||||
//
|
//
|
||||||
func (c *Config) Client() (*digitalocean.Client, error) {
|
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)
|
client, err := digitalocean.NewClient(c.Token)
|
||||||
|
|
||||||
log.Printf("[INFO] DigitalOcean Client configured for URL: %s", client.URL)
|
log.Printf("[INFO] DigitalOcean Client configured for URL: %s", client.URL)
|
||||||
|
|
|
@ -25,9 +25,16 @@ func TestResourceProvider_impl(t *testing.T) {
|
||||||
|
|
||||||
func TestResourceProvider_Configure(t *testing.T) {
|
func TestResourceProvider_Configure(t *testing.T) {
|
||||||
rp := new(ResourceProvider)
|
rp := new(ResourceProvider)
|
||||||
|
var expectedToken string
|
||||||
|
|
||||||
|
if v := os.Getenv("DIGITALOCEAN_TOKEN"); v != "foo" {
|
||||||
|
expectedToken = v
|
||||||
|
} else {
|
||||||
|
expectedToken = "foo"
|
||||||
|
}
|
||||||
|
|
||||||
raw := map[string]interface{}{
|
raw := map[string]interface{}{
|
||||||
"token": "foo",
|
"token": expectedToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
rawConfig, err := config.NewRawConfig(raw)
|
rawConfig, err := config.NewRawConfig(raw)
|
||||||
|
@ -41,7 +48,7 @@ func TestResourceProvider_Configure(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := Config{
|
expected := Config{
|
||||||
Token: "foo",
|
Token: expectedToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(rp.Config, expected) {
|
if !reflect.DeepEqual(rp.Config, expected) {
|
||||||
|
|
Loading…
Reference in New Issue