Skip to content

no-mocked-terraform-test-oracle

Warn when a Terraform assertion directly reasserts the same literal injected by a resource, data, or module override.

Why

An assertion that compares an overridden attribute directly with its authored override value is self-fulfilling; it does not exercise configuration logic or provider behavior.

Fix

Assert on configuration behavior derived from the override, or add provider-backed/runtime coverage for provider-dependent claims. Empty mock providers remain valid for fast configuration tests.

Examples

Before — flagged Assertion repeats its own resource override
tests/routing.tftest.hcl
override_resource {
target = aws_s3_bucket.main
values = { arn = "fixture-arn" }
}
run "routing" {
assert {
condition = aws_s3_bucket.main.arn == "fixture-arn"
error_message = "ARN mismatch"
}
}
After — preferred Empty mock provider validates configured plan behavior
tests/routing.tftest.hcl
mock_provider "aws" {}
run "routing" {
command = plan
assert {
condition = aws_s3_bucket.main.bucket == var.bucket_name
error_message = "bucket configuration drifted"
}
}

Formerly: no-terraform-test-file