Skip to content

Commit

Permalink
Un-export NewLocalRunner and AddLocalFile
Browse files Browse the repository at this point in the history
  • Loading branch information
bendrucker committed Jul 6, 2023
1 parent d10b04f commit 7633354
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions helper/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand All @@ -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
}
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions helper/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}

Expand Down

0 comments on commit 7633354

Please sign in to comment.