Skip to content

Commit

Permalink
test: add support for new config system in testAccPreCheck (scaleway#191
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jerome-quere authored Jul 1, 2019
1 parent dc60149 commit 3a1a580
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scaleway/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
homedir "github.com/mitchellh/go-homedir"
"github.com/scaleway/scaleway-sdk-go/scwconfig"
)

var testAccProviders map[string]terraform.ResourceProvider
Expand Down Expand Up @@ -38,6 +39,17 @@ func TestProvider_impl(t *testing.T) {
}

func testAccPreCheck(t *testing.T) {

// Handle new config system first
config, err := scwconfig.Load()
if err == nil {
_, hasAccessKey := config.GetAccessKey()
_, hasSecretKey := config.GetSecretKey()
if hasAccessKey && hasSecretKey {
return
}
}

if v := os.Getenv("SCALEWAY_ORGANIZATION"); v == "" {
if path, err := homedir.Expand("~/.scwrc"); err == nil {
scwAPIKey, scwOrganization, err := readDeprecatedScalewayConfig(path)
Expand Down

0 comments on commit 3a1a580

Please sign in to comment.