Documentation
¶
Overview ¶
Package rulestest provides test helpers for evaluating ruleshttp.Transport rules against declarative test cases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaseResult ¶
type CaseResult struct {
// Phase is "request" or "response".
Phase string
// Name is the test case name.
Name string
// Pass is true when the outcome matched Want.
Pass bool
// Reason is non-empty when Pass is false and describes why the case failed.
Reason string
}
CaseResult reports the outcome of a single test case.
func Run ¶
func Run(transport *ruleshttp.Transport, tests ConfigTestCase) []CaseResult
Run evaluates all request and response cases in tests against transport, returning one CaseResult per case in input order.
A ruleshttp evaluation error is recorded as a failure in the relevant CaseResult rather than returned.
type ConfigTestCase ¶
type ConfigTestCase struct {
Requests []RequestTestCase `yaml:"requests"`
Responses []ResponseTestCase `yaml:"responses"`
}
ConfigTestCase holds request and response test cases for use with Run.
type RequestTestCase ¶
type RequestTestCase struct {
Name string `yaml:"name"`
Want string `yaml:"want"` // "allow" or "deny"
Request ruleshttp.RequestEnv `yaml:"request"`
}
RequestTestCase is a single pre_request rule test.
type ResponseTestCase ¶
type ResponseTestCase struct {
Name string `yaml:"name"`
Want string `yaml:"want"` // "allow" or "deny"
Response ruleshttp.ResponseEnv `yaml:"response"`
}
ResponseTestCase is a single pre_response rule test.
Click to show internal directories.
Click to hide internal directories.