diff --git a/helper/runner.go b/helper/runner.go index e910840..10118a4 100644 --- a/helper/runner.go +++ b/helper/runner.go @@ -350,9 +350,8 @@ func (r *Runner) EnsureNoError(err error, proc func() error) error { return err } -// NewLocalRunner initialises a new test runner. -// Internal use only. -func NewLocalRunner(files map[string]*hcl.File, issues Issues) *Runner { +// newLocalRunner initialises a new test runner. +func newLocalRunner(files map[string]*hcl.File, issues Issues) *Runner { return &Runner{ files: map[string]*hcl.File{}, sources: map[string][]byte{}, @@ -361,9 +360,9 @@ func NewLocalRunner(files map[string]*hcl.File, issues Issues) *Runner { } } -// AddLocalFile adds a new file to the current mapped files. -// Internal use only. -func (r *Runner) AddLocalFile(name string, file *hcl.File) bool { +// addLocalFile adds a new file to the current mapped files. +// For testing only. Normally, the main TFLint process is responsible for loading files. +func (r *Runner) addLocalFile(name string, file *hcl.File) bool { if _, exists := r.files[name]; exists { return false } @@ -373,6 +372,8 @@ func (r *Runner) AddLocalFile(name string, file *hcl.File) bool { return true } +// initFromFiles initializes the runner from locally added files. +// For testing only. func (r *Runner) initFromFiles() error { for _, file := range r.files { content, _, diags := file.Body.PartialContent(configFileSchema) diff --git a/helper/testing.go b/helper/testing.go index 04b313d..c7d723c 100644 --- a/helper/testing.go +++ b/helper/testing.go @@ -19,7 +19,7 @@ import ( func TestRunner(t *testing.T, files map[string]string) *Runner { t.Helper() - runner := NewLocalRunner(map[string]*hcl.File{}, Issues{}) + runner := newLocalRunner(map[string]*hcl.File{}, Issues{}) parser := hclparse.NewParser() for name, src := range files { @@ -41,7 +41,7 @@ func TestRunner(t *testing.T, files map[string]string) *Runner { } runner.config = config } else { - runner.AddLocalFile(name, file) + runner.addLocalFile(name, file) } }