Documentation ¶
Index ¶
- Constants
- func AnyFailed(results []Result) bool
- func GenerateTestsSchema() (*openapi3.SchemaRef, error)
- func PrintProgress(w io.WriteCloser, results []Result)
- func PrintSummary(w io.WriteCloser, results []Result)
- type AnalysisParams
- type CountBasedVerification
- type IncidentVerification
- type LocationBasedVerification
- type LocationVerification
- type ProviderConfig
- type Result
- type ResultPrinter
- type Runner
- type Test
- type TestCase
- type TestOptions
- type TestsFile
- type TestsFilter
Constants ¶
const (
RULESET_TEST_CONFIG_GOLDEN_FILE = "testing-config.yaml"
)
Variables ¶
This section is empty.
Functions ¶
func GenerateTestsSchema ¶
func PrintProgress ¶
func PrintProgress(w io.WriteCloser, results []Result)
PrintProgress prints detailed information from given results
func PrintSummary ¶
func PrintSummary(w io.WriteCloser, results []Result)
PrintSummary prints statistical summary from given results
Types ¶
type AnalysisParams ¶
type AnalysisParams struct { // Mode analysis mode to use when running the test, one of - source-only, full Mode provider.AnalysisMode `yaml:"mode,omitempty" json:"mode,omitempty"` // DepLabelSelector dependency label selector to use when running the test DepLabelSelector string `yaml:"depLabelSelector,omitempty" json:"depLabelSelector,omitempty"` }
func (AnalysisParams) Validate ¶
func (a AnalysisParams) Validate() error
type CountBasedVerification ¶
type CountBasedVerification struct { // Exactly pass test case when there are exactly this many incidents Exactly *int `yaml:"exactly,omitempty" json:"exactly,omitempty"` // AtLeast pass test case when there are this many or more incidents AtLeast *int `yaml:"atLeast,omitempty" json:"atLeast,omitempty"` // AtMost pass test case when there are no more than this many incidents AtMost *int `yaml:"atMost,omitempty" json:"atMost,omitempty"` // MessageMatches pass test case when all incidents contain this message MessageMatches *string `yaml:"messageMatches,omitempty" json:"messageMatches,omitempty"` // CodeSnipMatches pass test case when all incidents contain this code snip CodeSnipMatches *string `yaml:"codeSnipMatches,omitempty" json:"codeSnipMatches,omitempty"` }
CountBasedVerification defines test case passing criteria based on count of incidents. Only one of exactly, atLeast, or atMost can be defined at a time.
type IncidentVerification ¶
type IncidentVerification struct { // CountBased defines a simple test case passing criteria based on count of incidents CountBased *CountBasedVerification `yaml:",inline,omitempty" json:",inline,omitempty"` // LocationBased defines a detailed test case passing criteria based on each incident LocationBased *LocationBasedVerification `yaml:",inline,omitempty" json:",inline,omitempty"` }
IncidentVerification defines criterias to pass a test case. Only one of CountBased or LocationBased can be defined at a time.
func (*IncidentVerification) MarshalYAML ¶
func (i *IncidentVerification) MarshalYAML() (interface{}, error)
func (IncidentVerification) Validate ¶
func (t IncidentVerification) Validate() error
type LocationBasedVerification ¶
type LocationBasedVerification struct { // Locations defines detailed conditions for each incident Locations []LocationVerification `yaml:"locations" json:"locations"` }
type LocationVerification ¶
type LocationVerification struct { // FileURI is the file in which incident is supposed to be found FileURI *string `yaml:"fileURI,omitempty" json:"fileURI,omitempty"` // LineNumber is the line number where incident is supposed to be found LineNumber *int `yaml:"lineNumber,omitempty" json:"lineNumber,omitempty"` // MessageMatches is the message that's supposed to be contained within the message of this incident MessageMatches *string `yaml:"messageMatches,omitempty" json:"messageMatches,omitempty"` // CodeSnipMatches is the code snippet which is supposed to be present within the codeSnip of this incident CodeSnipMatches *string `yaml:"codeSnipMatches,omitempty" json:"codeSnipMatches,omitempty"` }
LocationVerification defines test case passing criteria based on detailed information in an incident. FileURI and LineNumber are required.
func (LocationVerification) Validate ¶
func (l LocationVerification) Validate() error
type ProviderConfig ¶
type ProviderConfig struct { // Name is the name of the provider this config applies to Name string `yaml:"name" json:"name"` // DataPath is a relative path to test data to be used for this provider DataPath string `yaml:"dataPath" json:"dataPath"` }
func (ProviderConfig) Validate ¶
func (p ProviderConfig) Validate() error
type Result ¶
type Result struct { Passed bool TestsFilePath string RuleID string TestCaseName string DebugInfo []string FailureReasons []string Error error }
Result is a result of a test run
type ResultPrinter ¶
type ResultPrinter func(io.WriteCloser, []Result)
ResultPrinter is a function to print given results to a given place
type Runner ¶
type Runner interface {
Run([]TestsFile, TestOptions) ([]Result, error)
}
Runner given a list of TestsFile and a TestOptions runs the tests, computes and returns results
type Test ¶
type TestCase ¶
type TestCase struct { // Name is a unique name for this test case Name string `yaml:"name" json:"name"` // AnalysisParams is analysis parameters to be used when running this test case AnalysisParams `yaml:"analysisParams,omitempty" json:"analysisParams,omitempty"` // IsUnmatched passes test case when the rule is not matched IsUnmatched bool `yaml:"isUnmatched,omitempty" json:"isUnmatched,omitempty"` // HasIncidents defines criteria to pass the test case based on incidents for this rule HasIncidents *IncidentVerification `yaml:"hasIncidents,omitempty" json:"hasIncidents,omitempty"` // HasTags passes test case when all of the given tags are generated HasTags []string `yaml:"hasTags,omitempty" json:"hasTags,omitempty"` RuleID string `yaml:"-" json:"-"` }
type TestOptions ¶
type TestsFile ¶
type TestsFile struct { // RulesPath is an optional path to respective rules file RulesPath string `yaml:"rulesPath,omitempty" json:"rulesPath,omitempty"` // Providers is a list of configs with each item containing config specific to a provider Providers []ProviderConfig `yaml:"providers,omitempty" json:"providers,omitempty"` // Tests is a list of tests with each item defining one or more test cases specific to a rule Tests []Test `yaml:"tests,omitempty" json:"tests,omitempty"` Path string `yaml:"-" json:"-"` }
type TestsFilter ¶
TestsFilter filters in-out tests/test cases and returns final list of things to run
func NewInlineNameBasedFilter ¶
func NewInlineNameBasedFilter(names string) TestsFilter
NewInlineNameBasedFilter works on an input string containing a comma separated list of test names and test case names to include