Skip to content
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

fix: apply opts and test #1088

Merged
merged 1 commit into from
Feb 9, 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
5 changes: 5 additions & 0 deletions lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func New(rules RuleRegistry, configs Configs, opts ...LinterOption) *Linter {
rules: rules,
configs: configs,
}

for _, opt := range opts {
opt(l)
}

return l
}

Expand Down
26 changes: 26 additions & 0 deletions lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,29 @@ func TestLinter_LintProtos_RulePanics(t *testing.T) {
})
}
}

func TestLinter_debug(t *testing.T) {
tests := []struct {
name string
debug bool
}{
{
name: "debug",
debug: true,
},
{
name: "do not debug",
debug: false,
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
l := New(NewRuleRegistry(), nil, Debug(test.debug))

if a, e := l.debug, test.debug; a != e {
t.Errorf("got debug %v wanted debug %v", a, e)
}
})
}
}