-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Closed
Labels
Description
Terraform Version
Terraform v1.8.1
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v5.25.0Use Cases
With terraform test you can now run tests from the root of a repo even if the root has no .tf files. A directory structure like this can't run tests unless an empty.tf file is added because we can't fully initialize with terraform init.
This is a current test/WA:
❯ terraform test -verbose
╷
│ Error: Module not installed
│
│ on tests/default.tftest.hcl line 4, in run "test":
│ 4: module {
│
│ This module is not yet installed. Run "terraform init" to install all modules required by this configuration.
╵
❯ terraform init
Terraform initialized in an empty directory!
The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.
❯ terraform test -verbose
╷
│ Error: Module not installed
│
│ on tests/default.tftest.hcl line 4, in run "test":
│ 4: module {
│
│ This module is not yet installed. Run "terraform init" to install all modules required by this configuration.
╵
❯ touch empty.tf
❯ terraform init
Initializing the backend...
Initializing modules...
- test.tests.default.test in tests/fixtures/default
- test.tests.default.test.test in global
Initializing provider plugins...
- Finding latest version of hashicorp/google...
- Installing hashicorp/google v5.25.0...
- Installed hashicorp/google v5.25.0 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
❯ terraform test
tests/default.tftest.hcl... in progress
run "test"... pass
tests/default.tftest.hcl... tearing down
tests/default.tftest.hcl... pass
Success! 1 passed, 0 failed.
Attempted Solutions
add empty.tf, change directory structure.
Proposal
No response
References
No response
miguelsantosmindera and diogonborges
