Skip to content

Commit

Permalink
Adds a test for the template linter
Browse files Browse the repository at this point in the history
  • Loading branch information
bvobart committed Jun 13, 2021
1 parent 1876535 commit 0d90fcb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions linters/template/linter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package template_test

import (
"errors"
stdtesting "testing"

"github.com/bvobart/mllint/api"
"github.com/bvobart/mllint/config"
"github.com/bvobart/mllint/linters/template"
"github.com/bvobart/mllint/linters/testutils"
"github.com/bvobart/mllint/utils"
"github.com/stretchr/testify/require"
)

// This test serves as an example test for a linter.
// When implementing a new linter, copy and edit this test to use the linter you're implementing,
// and create a suite of integration tests that cover the functionality of the linter.
//
// You can use options on the suite or on the test in order to e.g. specify which Python files to set on the project,
// supply a specific Config that will be passed to the linter if it implements api.Configurable,
// or provide / auto-detect the dependency managers in the project.
func TestTemplateLinter(t *stdtesting.T) {
linter := template.NewLinter()
require.Equal(t, "Linter Template", linter.Name())
require.Equal(t, []*api.Rule{&template.RuleSomething}, linter.Rules())

suite := testutils.NewLinterTestSuite(linter, []testutils.LinterTest{
{
Name: "ExampleTest",
Dir: ".",
Options: testutils.NewOptions().WithConfig(config.Default()),
Expect: func(report api.Report, err error) {
require.Error(t, err, errors.New("not implemented"))
require.EqualValues(t, 80, report.Scores[template.RuleSomething])
},
},
})
// use DefaultOptions to edit the options that will be applied to every test (unless overridden by test options)
suite.DefaultOptions().UsePythonFiles(utils.Filenames{"example.py"})
suite.RunAll(t)
}

0 comments on commit 0d90fcb

Please sign in to comment.