Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
84eb3bd0
Commit
84eb3bd0
authored
Nov 14, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for supporting for with all alerting scenarios
parent
8fb997d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
pkg/services/alerting/eval_context_test.go
+44
-0
No files found.
pkg/services/alerting/eval_context_test.go
View file @
84eb3bd0
...
...
@@ -139,6 +139,50 @@ func TestGetStateFromEvalContext(t *testing.T) {
ec
.
NoDataFound
=
true
},
},
{
name
:
"pending -> no_data(alerting) with for duration have not passed"
,
expected
:
models
.
AlertStatePending
,
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStatePending
ec
.
Rule
.
NoDataState
=
models
.
NoDataSetAlerting
ec
.
NoDataFound
=
true
ec
.
Rule
.
For
=
time
.
Minute
*
5
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
2
)
},
},
{
name
:
"pending -> no_data(alerting) should set alerting since time passed FOR"
,
expected
:
models
.
AlertStateAlerting
,
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStatePending
ec
.
Rule
.
NoDataState
=
models
.
NoDataSetAlerting
ec
.
NoDataFound
=
true
ec
.
Rule
.
For
=
time
.
Minute
*
2
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
5
)
},
},
{
name
:
"pending -> error(alerting) with for duration have not passed "
,
expected
:
models
.
AlertStatePending
,
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStatePending
ec
.
Rule
.
ExecutionErrorState
=
models
.
ExecutionErrorSetAlerting
ec
.
Error
=
errors
.
New
(
"test error"
)
ec
.
Rule
.
For
=
time
.
Minute
*
5
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
2
)
},
},
{
name
:
"pending -> error(alerting) should set alerting since time passed FOR"
,
expected
:
models
.
AlertStateAlerting
,
applyFn
:
func
(
ec
*
EvalContext
)
{
ec
.
PrevAlertState
=
models
.
AlertStatePending
ec
.
Rule
.
ExecutionErrorState
=
models
.
ExecutionErrorSetAlerting
ec
.
Error
=
errors
.
New
(
"test error"
)
ec
.
Rule
.
For
=
time
.
Minute
*
2
ec
.
Rule
.
LastStateChange
=
time
.
Now
()
.
Add
(
-
time
.
Minute
*
5
)
},
},
}
for
_
,
tc
:=
range
tcs
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment