Enforce terraform fmt in examples

This commit is contained in:
Julio Castillo
2022-12-16 12:53:56 +01:00
parent 0faf8ae1f1
commit e700a27079
45 changed files with 368 additions and 360 deletions

View File

@@ -13,6 +13,7 @@
# limitations under the License.
import re
import subprocess
from pathlib import Path
BASE_PATH = Path(__file__).parent
@@ -52,5 +53,12 @@ def test_example(plan_validator, tmp_path, example):
assert expected_modules == num_modules, 'wrong number of modules'
assert expected_resources == num_resources, 'wrong number of resources'
# TODO(jccb): this should probably be done in check_documentation
# but we already have all the data here.
result = subprocess.run(
'terraform fmt -check -diff -no-color main.tf'.split(), cwd=tmp_path,
stdout=subprocess.PIPE, encoding='utf-8')
assert result.returncode == 0, f'terraform code not formatted correctly\n{result.stdout}'
else:
assert False, "can't find tftest directive"