End-to-end tests for terraform modules (#1751)

Add end-to-end tests (apply, plan, destroy) for examples.

When run, `tests/examples_e2e`:
1. Create an environment for tests to run (folder, project vpc network) 
2. For each marked example (with `e2e` tftest directive), run apply, plan, destroy
3. Verify:
* no failure in apply
* empty plan after apply
* no failure during destroy
4. When all tests are done, destroy test environment

More details in `tests/examples_e2e/README.md`
This commit is contained in:
Wiktor Niesiobędzki
2023-10-20 09:59:52 +02:00
committed by GitHub
parent 4e439720aa
commit d07daf966a
16 changed files with 619 additions and 30 deletions

View File

@@ -28,6 +28,10 @@ def test_example(plan_validator, tmp_path, example):
(tmp_path / 'fabric').symlink_to(BASE_PATH.parents[1])
(tmp_path / 'variables.tf').symlink_to(BASE_PATH / 'variables.tf')
(tmp_path / 'main.tf').write_text(example.code)
assets_path = BASE_PATH.parent / str(example.module).replace('-',
'_') / 'assets'
if assets_path.exists():
(tmp_path / 'assets').symlink_to(assets_path)
expected_modules = int(match.group(1))
expected_resources = int(match.group(2))