-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): refactor NE acceptance+sweep tests to avoid import cycles
Signed-off-by: Marques Johansson <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,659 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,11 @@ | ||
package equinix | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/equinix/terraform-provider-equinix/internal/config" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
const tstResourcePrefix = "tfacc" | ||
|
||
func TestMain(m *testing.M) { | ||
resource.TestMain(m) | ||
} | ||
|
||
func sharedConfigForRegion(region string) (*config.Config, error) { | ||
endpoint := getFromEnvDefault(config.EndpointEnvVar, config.DefaultBaseURL) | ||
clientToken := getFromEnvDefault(config.ClientTokenEnvVar, "") | ||
clientID := getFromEnvDefault(config.ClientIDEnvVar, "") | ||
clientSecret := getFromEnvDefault(config.ClientSecretEnvVar, "") | ||
clientTimeout := getFromEnvDefault(config.ClientTimeoutEnvVar, strconv.Itoa(config.DefaultTimeout)) | ||
clientTimeoutInt, err := strconv.Atoi(clientTimeout) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot convert value of '%s' env variable to int", config.ClientTimeoutEnvVar) | ||
} | ||
metalAuthToken := getFromEnvDefault(config.MetalAuthTokenEnvVar, "") | ||
|
||
if clientToken == "" && (clientID == "" || clientSecret == "") && metalAuthToken == "" { | ||
return nil, fmt.Errorf("To run acceptance tests sweeper, one of '%s' or pair '%s' - '%s' must be set for Equinix Fabric and Network Edge, and '%s' for Equinix Metal", | ||
config.ClientTokenEnvVar, config.ClientIDEnvVar, config.ClientSecretEnvVar, config.MetalAuthTokenEnvVar) | ||
} | ||
|
||
return &config.Config{ | ||
AuthToken: metalAuthToken, | ||
BaseURL: endpoint, | ||
Token: clientToken, | ||
ClientID: clientID, | ||
ClientSecret: clientSecret, | ||
RequestTimeout: time.Duration(clientTimeoutInt) * time.Second, | ||
}, nil | ||
} | ||
|
||
func isSweepableTestResource(namePrefix string) bool { | ||
return strings.HasPrefix(namePrefix, tstResourcePrefix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package acceptance | ||
|
||
import ( | ||
"github.com/equinix/terraform-provider-equinix/equinix" | ||
"github.com/equinix/terraform-provider-equinix/internal/provider" | ||
"github.com/equinix/terraform-provider-equinix/version" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
func init() { | ||
TestAccProvider = equinix.Provider() | ||
TestAccProviders = map[string]*schema.Provider{ | ||
"equinix": TestAccProvider, | ||
} | ||
TestExternalProviders = map[string]resource.ExternalProvider{ | ||
"random": { | ||
Source: "hashicorp/random", | ||
}, | ||
} | ||
TestAccFrameworkProvider = provider.CreateFrameworkProvider(version.ProviderVersion).(*provider.FrameworkProvider) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.