base_rule_test.go
base_rule_test.go - Overview
-
Overview The
base_rule_test.go
file contains unit tests for theBaseRule
struct, specifically focusing on theShouldAlert
method and its behavior whenRequireMinPoints
is enabled. -
Detailed Documentation
Function: TestBaseRule_RequireMinPoints
- Purpose: Tests the
ShouldAlert
method ofBaseRule
whenRequireMinPoints
is enabled in the rule condition. - Parameters:
t
:*testing.T
- Testing object for running test cases.
Test Cases
test should skip if less than min points
: Checks if the rule skips evaluation when the number of data points in the series is less thanRequiredNumPoints
.test should alert if more than min points
: Checks if the rule triggers an alert when the number of data points in the series is greater than or equal toRequiredNumPoints
and the value satisfies the condition.
Test Structure
Each test case defines:
name
: Name of the test case.rule
:*BaseRule
- TheBaseRule
instance with specificRuleCondition
.shouldAlert
:bool
- Expected value ofshouldAlert
returned byShouldAlert
method.series
:*v3.Series
- Thev3.Series
instance representing the time series data.
Include in Getting Started: NO