Skip to content

Commit

Permalink
chore: Minor cleanup for tftest (#32)
Browse files Browse the repository at this point in the history
* Minor cleanup for tftest
* Fixup race condition
  • Loading branch information
baolsen authored Nov 25, 2022
1 parent 5c19ee7 commit 11d6abc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.74.1
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_docs
args:
- '--args=--lockfile=false'
- --args=--lockfile=false
- --args=--config=.tfdocs-config.yml
- id: terraform_fmt
- id: terraform_validate
- id: terraform_tflint
args:
- '--args=--only=terraform_deprecated_interpolation'
Expand Down
2 changes: 1 addition & 1 deletion .tfdocs-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ settings:
hide-empty: false
html: true
indent: 3
lockfile: true
lockfile: false
read-comments: true
required: true
sensitive: true
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ locals {

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.38.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9, <5 |

----
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9, <5 |
| <a name="requirement_http"></a> [http](#requirement\_http) | 3.0.1 |

----
Expand Down
12 changes: 4 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def config(config_file) -> dict:
return {}
else:
raise FileNotFoundError(config_file)
return config


@pytest.fixture(scope="session")
Expand All @@ -51,13 +50,6 @@ def terraform_default_variables(request, config):
variables = {}
for name, value in config.get("variables", {}).items():
variables[name] = value
"""value = None
if variable_config.get("parameter", False):
value = request.config.getoption(variable_config["parameter"])
if variable_config.get("required", False):
if value is None:
raise Exception(f"Variable {variable} must be specified.")
variables[variable] = value"""
return variables


Expand Down Expand Up @@ -148,5 +140,9 @@ def terraform_apply_and_output(test_name, terraform_config, variables=None):
try:
tf.apply()
yield tf.output()
# Shorten the default exception message.
except tftest.TerraformTestError as e:
tf.destroy(**{"auto_approve": True})
raise tftest.TerraformTestError(e.cmd_error) from e
finally:
tf.destroy(**{"auto_approve": True})
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.9"
version = ">= 4.9, <5"
}
http = {
source = "hashicorp/http"
Expand Down

0 comments on commit 11d6abc

Please sign in to comment.