Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FailedTest ¶
FailedTest includes all the errors of a failed test.
func (FailedTest) String ¶
func (t FailedTest) String() string
type Result ¶
type Result struct { OK bool NumTests int Failed []FailedTest }
Result represents the result of a series of tests.
type Rule ¶
type Rule struct { Eval RuleEvaluator Actions Actions }
Rule represents a filter that can evaluate whether messages apply to it.
type RuleEvaluator ¶
type RuleEvaluator interface { // Match returns true if the given message matches the filter criteria. Match(msg cfg.Message) bool }
RuleEvaluator represents a filter criteria able to evaluate if an email matches its definition.
func NewEvaluator ¶
func NewEvaluator(criteria parser.CriteriaAST) (RuleEvaluator, error)
NewEvaluator creates a RuleEvaluator starting from a parser criteria.
type Rules ¶
type Rules []Rule
Rules is a set of rules.
func NewFromParserRules ¶
NewFromParserRules translates parser Rules into test Rules.
This function is best effort. Every criteria that is not convertible is going to be ignored and an error is returned in its place. The resulting rules will contain only the valid rules.
func (Rules) ExecTest ¶
ExecTest evaluates the rules on all the messages of the given test.
If the rules apply as expected by the test, no error is returned.
func (Rules) ExecTests ¶
ExecTests evaluates all the rules against the given tests.
The evaluation stops at the first failing test.
func (Rules) MatchingActions ¶
MatchingActions returns the actions that would be applied by the rules if the given message arrived.
An error can be returned if multiple incompatible actions would be applied. Note that in Gmail this wouldn't be an error, but a nondeterministic action would be applied. Since this situation is most likely a mistake by the user, we treat it as an error.