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
a70ea210
Commit
a70ea210
authored
Nov 15, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alertmanager: adds tests for should notify
parent
28029ce4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
pkg/services/alerting/notifiers/alertmanager_test.go
+47
-0
No files found.
pkg/services/alerting/notifiers/alertmanager_test.go
View file @
a70ea210
package
notifiers
import
(
"context"
"testing"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/log"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/alerting"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestWhenAlertManagerShouldNotify
(
t
*
testing
.
T
)
{
tcs
:=
[]
struct
{
prevState
m
.
AlertStateType
newState
m
.
AlertStateType
expect
bool
}{
{
prevState
:
m
.
AlertStatePending
,
newState
:
m
.
AlertStateOK
,
expect
:
false
,
},
{
prevState
:
m
.
AlertStateAlerting
,
newState
:
m
.
AlertStateOK
,
expect
:
true
,
},
{
prevState
:
m
.
AlertStateOK
,
newState
:
m
.
AlertStatePending
,
expect
:
false
,
},
{
prevState
:
m
.
AlertStateUnknown
,
newState
:
m
.
AlertStatePending
,
expect
:
false
,
},
}
for
_
,
tc
:=
range
tcs
{
am
:=
&
AlertmanagerNotifier
{
log
:
log
.
New
(
"test.logger"
)}
evalContext
:=
alerting
.
NewEvalContext
(
context
.
TODO
(),
&
alerting
.
Rule
{
State
:
tc
.
prevState
,
})
evalContext
.
Rule
.
State
=
tc
.
newState
res
:=
am
.
ShouldNotify
(
context
.
TODO
(),
evalContext
,
&
m
.
AlertNotificationState
{})
if
res
!=
tc
.
expect
{
t
.
Errorf
(
"got %v expected %v"
,
res
,
tc
.
expect
)
}
}
}
func
TestAlertmanagerNotifier
(
t
*
testing
.
T
)
{
Convey
(
"Alertmanager notifier tests"
,
t
,
func
()
{
...
...
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