Running all the tests for this provider requires access to Terraform Cloud with a full feature set; most tests can be run against your own installation of Terraform Enterprise.
If you are planning to run the full suite of tests or work on policy sets, registry modules, or workspaces, you'll need to set up repositories for them in GitHub.
Your policy set repository will need the following:
- A policy set stored in a subdirectory
- A branch other than master
Your registry module repository will need to be a valid module. It will need the following:
- To be named
terraform-<PROVIDER>-<NAME>
- At least one valid SemVer tag in the format
x.y.z
terraform-random-module is a good example repo.
Your workspace repository will need the following:
- A branch other than master
To run all tests, you will need to set the following environment variables:
A hostname and token must be provided in order to run the acceptance tests. By
default, these are loaded from the the credentials
in the CLI config
file. You can override
these values with the environment variables specified below:
TFE_HOSTNAME
- URL of a Terraform Cloud or Terraform Enterprise instance to be used for testing, without the scheme. Example:tfe.local
TFE_TOKEN
- A user API token for an administrator account on the Terraform Cloud or Terraform Enterprise instance being used for testing.
TFE_USER1
andTFE_USER2
: The usernames of two pre-existing users on the Terraform Cloud or Terraform Enterprise instance being used for testing. Required for running team membership tests.GITHUB_TOKEN
- GitHub personal access token. Used to establish a VCS provider connection.GITHUB_POLICY_SET_IDENTIFIER
- GitHub policy set repository identifier in the formatusername/repository
. Required for running policy set tests.GITHUB_POLICY_SET_BRANCH
: A GitHub branch for the repository specified byGITHUB_POLICY_SET_IDENTIFIER
. Required for running policy set tests.GITHUB_POLICY_SET_PATH
: A GitHub subdirectory for the repository specified byGITHUB_POLICY_SET_IDENTIFIER
. Required for running policy set tests.GITHUB_REGISTRY_MODULE_IDENTIFIER
- GitHub registry module repository identifier in the formatusername/repository
. Required for running registry module tests.GITHUB_WORKSPACE_IDENTIFIER
- GitHub workspace repository identifier in the formatusername/repository
. Required for running workspace tests.GITHUB_WORKSPACE_BRANCH
: A GitHub branch for the repository specified byGITHUB_WORKSPACE_IDENTIFIER
. Required for running workspace tests.
You can set your environment variables up however you prefer. The following are instructions for setting up environment variables using envchain.
-
Make sure you have envchain installed. Instructions for this can be found in the envchain README.
-
Pick a namespace for storing your environment variables. I suggest
terraform-provider-tfe
or something similar. -
For each environment variable you need to set, run the following command:
envchain --set YOUR_NAMESPACE_HERE ENVIRONMENT_VARIABLE_HERE
OR
Set all of the environment variables at once with the following command:
envchain --set YOUR_NAMESPACE_HERE TFE_HOSTNAME TFE_TOKEN TFE_USER1 TFE_USER2 GITHUB_TOKEN GITHUB_POLICY_SET_IDENTIFIER GITHUB_POLICY_SET_BRANCH GITHUB_POLICY_SET_PATH GITHUB_REGISTRY_MODULE_IDENTIFIER GITHUB_WORKSPACE_IDENTIFIER GITHUB_WORKSPACE_BRANCH
$ envchain YOUR_NAMESPACE_HERE make test
$ make test
$ envchain YOUR_NAMESPACE_HERE make testacc
$ make testacc
The commands below use notification configurations as an example.
$ TESTARGS="-run TestAccTFENotificationConfiguration" envchain YOUR_NAMESPACE_HERE make testacc
$ TESTARGS="-run TestAccTFENotificationConfiguration" make testacc