Documentation ¶
Overview ¶
Package helper contains implementations for plugin testing.
You can test the implemented rules using the mock Runner that is not an RPC client. It is similar to TFLint's Runner, but is implemented from scratch to avoid Terraform dependencies.
Some implementations of the mock Runner have been simplified. As a result, note that some features may not behave exactly as they should.
Index ¶
- func AssertIssues(t *testing.T, expected Issues, actual Issues)
- func AssertIssuesWithoutRange(t *testing.T, expected Issues, actual Issues)
- type Issue
- type Issues
- type Runner
- func (r *Runner) Backend() (*configs.Backend, error)
- func (r *Runner) Config() (*configs.Config, error)
- func (r *Runner) EmitIssue(rule tflint.Rule, message string, location hcl.Range) error
- func (r *Runner) EmitIssueOnExpr(rule tflint.Rule, message string, expr hcl.Expression) error
- func (r *Runner) EnsureNoError(err error, proc func() error) error
- func (r *Runner) EvaluateExpr(expr hcl.Expression, ret interface{}) error
- func (r *Runner) EvaluateExprType(expr hcl.Expression, ret interface{}, wantType cty.Type) error
- func (r *Runner) WalkModuleCalls(walker func(*configs.ModuleCall) error) error
- func (r *Runner) WalkResourceAttributes(resourceType, attributeName string, walker func(*hcl.Attribute) error) error
- func (r *Runner) WalkResourceBlocks(resourceType, blockType string, walker func(*hcl.Block) error) error
- func (r *Runner) WalkResources(resourceType string, walker func(*configs.Resource) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertIssues ¶
AssertIssues is an assertion helper for comparing issues.
Types ¶
type Issue ¶
Issue is a stub that has the same structure as the actually used issue object. This is only used for testing, as the mock Runner doesn't depend on the actual Issue structure.
type Runner ¶
Runner is a mock that satisfies the Runner interface for plugin testing.
func TestRunner ¶
TestRunner returns a mock Runner for testing. You can pass the map of file names and their contents in the second argument.
func (*Runner) EmitIssueOnExpr ¶
EmitIssueOnExpr adds an issue to the runner itself.
func (*Runner) EnsureNoError ¶
EnsureNoError is a method that simply runs a function if there is no error.
func (*Runner) EvaluateExpr ¶
EvaluateExpr returns a value of the passed expression. Note that there is no evaluation, no type conversion, etc.
func (*Runner) EvaluateExprType ¶
EvaluateExprType returns a value of the passed expression. Note that there is no evaluation, no type conversion, etc.
func (*Runner) WalkModuleCalls ¶
func (r *Runner) WalkModuleCalls(walker func(*configs.ModuleCall) error) error
WalkModuleCalls visits all module calls from Files.
func (*Runner) WalkResourceAttributes ¶
func (r *Runner) WalkResourceAttributes(resourceType, attributeName string, walker func(*hcl.Attribute) error) error
WalkResourceAttributes visits all specified attributes from Files.