hashicorp / terraform-config-inspect

A helper library for shallow inspection of Terraform configurations
Mozilla Public License 2.0
381 stars 76 forks source link

tfconfig: Test for handling of a block with its brace on the next line #5

Closed apparentlymart closed 5 years ago

apparentlymart commented 5 years ago

This new test is covering a syntax error case that we were previously not handling gracefully. The change is actually in the HCL2 repository, to make this return a non-nil empty body in the case of a syntax error, but since this codebase is relying on that we'll test it up here too, to reduce the risk of this inadvertently regressing in future.

A convention in HCL2 is that functions which return diagnostics should return a "best effort" valid-but-possibly-incomplete object when returning errors, since this then allows some careful analysis of the partial object to generate a more complete set of errors. We don't return nil bodies in any other case, so it's best here to return an empty one to meet the "valid-but-incomplete" requirement.