Skip to content

How to evaluate optional() defaults #1996

Answered by wata727
matt-FFFFFF asked this question in Q&A
Discussion options

You must be logged in to vote

Understood. The test runner is not fully compatible with the real runner, and this is a documented behavior.
https://pkg.go.dev/github.com/terraform-linters/[email protected]/helper#Runner.EvaluateExpr

Since the test runner only supports simple evaluation, we recommend that you only ensure that your unit tests can evaluate with EvaluateExpr. Plugins shouldn't have to do much to evaluate complex expressions, so you can think of it as the SDK's responsibility.

If you still need to test complex cases, we recommend implementing integration tests. Below is an example implementation of integration testing in AWS ruleset.
https://github.com/terraform-linters/tflint-ruleset-aws/tree/v0.30…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@matt-FFFFFF
Comment options

@matt-FFFFFF
Comment options

@matt-FFFFFF
Comment options

@wata727
Comment options

Answer selected by matt-FFFFFF
@matt-FFFFFF
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants