Documentation ¶
Overview ¶
Package testutil contains methods to test checkers.
Index ¶
- func Contains(str string) func(err error) error
- func HasSuffix(suffix string) func(err error) error
- func MatchesRegexp(re string) func(err error) error
- func NoError(err error) error
- func Skip(s lint.Skipper, then func(error) error) func(err error) error
- func SkippedErrors(pattern string) func(error) error
- func Test(t Errorer, pkg string, tests []StaticCheckTest)
- func TestArgs(t Errorer, tests []ArgTest)
- func TestSkips(t Errorer, tests []SkipTest)
- type ArgTest
- type Arger
- type Errorer
- type SkipTest
- type StaticCheckMultiFileTest
- type StaticCheckTest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasSuffix ¶
HasSuffix returns a function that checks that an error is returned which has the provided suffix.
func MatchesRegexp ¶
MatchesRegexp returns a function that checks that an error is return which matches the provided regexp.
func SkippedErrors ¶
SkippedErrors returns a function that skips all errors matching pattern and verifies there are no errors left.
func Test ¶
func Test(t Errorer, pkg string, tests []StaticCheckTest)
Test runs the provided StaticCheckTests for pkg. Errors are reported using Errorer.
Types ¶
type Arger ¶
type Arger interface {
Args() []string
}
Arger holds the Args method that returns a list of command line arguments
type Errorer ¶
type Errorer interface {
Error(args ...interface{})
}
Errorer is used to report Errors. testing.T can be used as an Errorer.
type StaticCheckMultiFileTest ¶
type StaticCheckMultiFileTest struct { // Contents are the contents of the created files. Contents [][]byte // Checker is the checker to run on the package. Checker lint.Checker // Validate returns nil if err is what is expected. Validate func(err error) error }
StaticCheckMultiFileTest is a table-driven test for a checker testing a package with multiple files.
func (StaticCheckMultiFileTest) Test ¶
func (s StaticCheckMultiFileTest) Test(pkg string) error
Test runs the multifile test for pkg.
type StaticCheckTest ¶
type StaticCheckTest struct { // File is a src file to use instead of Content. File string // Content is the content of the created file. Content []byte // Checker is the checker to run on the package. Checker lint.Checker // Validate returns nil if err is what is expected. Validate func(err error) error }
StaticCheckTest is a table-driven test for a checker.
func (StaticCheckTest) Test ¶
func (s StaticCheckTest) Test(pkg string) error
Test runs the test for pkg.