ci: add Terraform mock unit tests for all templates for #71 (Phase 2)#102
Merged
ci: add Terraform mock unit tests for all templates for #71 (Phase 2)#102
Conversation
Adds tests/ directory to each template with validate.tftest.hcl using Terraform 1.7+ mock providers. Tests cover: plan succeeds with defaults, docker_container created when start_count=1, cpu/memory validation bounds. freeform also tests enable_adminer toggle. drupal-core supplies the required cache_path variable in each run block. Adds terraform test step to the validate workflow (runs after validate in the same matrix job) and make test-templates for local use. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Issue
Part of #71 (automated testing). Phase 2: Terraform mock unit tests that run with no live infrastructure.
How This PR Solves The Issue
Adds a
tests/validate.tftest.hclfile to each of the three templates using Terraform 1.7+ mock providers. The tests run entirely locally — no Coder server, no Docker, no credentials needed.Tests per template:
docker_containercreated whenstart_count=1cpubelow minimum (0) rejectedcpuabove maximum (33) rejectedmemorybelow minimum (1 GB) rejectedmemoryabove maximum (129 GB) rejectedenable_admineroff by defaultenable_adminercreatescoder_appOne non-obvious mock requirement:
vscode_extensions.valueis passed throughjsondecode()in locals across all three templates, so thecoder_parametermock overrides the default random string with"[]"(a valid empty JSON array).drupal-corerequirescache_pathin every run block since it has no default (tracked in #99 for removal).Also adds
terraform teststep to the existing validate workflow matrix job andmake test-templatesfor local use.Manual Testing Instructions
Automated Testing Overview
This PR extends the workflow added in #100. The
terraform teststep runs afterterraform validatein the same matrix job for each template. CI will run these 20 tests on every push and PR.Release/Deployment Notes
No impact on deployed templates or workspaces. CI-only change.