helper

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2020 License: MPL-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertIssues

func AssertIssues(t *testing.T, expected Issues, actual Issues)

AssertIssues is an assertion helper for comparing issues

func AssertIssuesWithoutRange

func AssertIssuesWithoutRange(t *testing.T, expected Issues, actual Issues)

AssertIssuesWithoutRange is an assertion helper for comparing issues

Types

type Issue

type Issue struct {
	Rule    tflint.Rule
	Message string
	Range   hcl.Range
}

Issue is a stub that has the same structure as the actually used issue object. This is only used for testing, as the Runner client doesn't depend on the actual Issue structure.

type Issues

type Issues []*Issue

Issues is a list of Issue

type Runner

type Runner struct {
	Files  map[string]*hcl.File
	Issues Issues
}

Runner is a pseudo Runner client provided for plugin testing. Actually, it is provided as an RPC client, but for the sake of simplicity, only the methods that satisfy the minimum required Runner interface are implemented. Specifically, there are restrictions on evaluation, annotation comments, module inspection, and so on.

func TestRunner

func TestRunner(t *testing.T, files map[string]string) *Runner

TestRunner returns a pseudo Runner for testing

func (*Runner) EmitIssue

func (r *Runner) EmitIssue(rule tflint.Rule, message string, location hcl.Range, meta tflint.Metadata) error

EmitIssue adds an issue into the self

func (*Runner) EnsureNoError

func (r *Runner) EnsureNoError(err error, proc func() error) error

EnsureNoError is a method that simply run a function if there is no error

func (*Runner) EvaluateExpr

func (r *Runner) EvaluateExpr(expr hcl.Expression, ret interface{}) error

EvaluateExpr returns a value of the passed expression. Note that there is no evaluation, no type conversion, etc.

func (*Runner) WalkResourceAttributes

func (r *Runner) WalkResourceAttributes(resourceType, attributeName string, walker func(*hcl.Attribute) error) error

WalkResourceAttributes searches for resources and passes the appropriate attributes to the walker function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL