Skip to content

Un-export NewLocalRunner and AddLocalFile #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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