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
dc3a62da
Commit
dc3a62da
authored
Nov 04, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added slack tests , fixed webhook tests
parent
2f60929d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
4 deletions
+85
-4
pkg/services/alerting/notifiers/slack_test.go
+81
-0
pkg/services/alerting/notifiers/webhook_test.go
+4
-4
No files found.
pkg/services/alerting/notifiers/slack_test.go
0 → 100644
View file @
dc3a62da
package
notifiers
import
(
"testing"
"github.com/grafana/grafana/pkg/components/simplejson"
m
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestSlackNotifier
(
t
*
testing
.
T
)
{
Convey
(
"Slack notifier tests"
,
t
,
func
()
{
Convey
(
"Parsing alert notification from settings"
,
func
()
{
Convey
(
"empty settings should return error"
,
func
()
{
json
:=
`{ }`
settingsJSON
,
_
:=
simplejson
.
NewJson
([]
byte
(
json
))
model
:=
&
m
.
AlertNotification
{
Name
:
"ops"
,
Type
:
"slack"
,
Settings
:
settingsJSON
,
}
_
,
err
:=
NewSlackNotifier
(
model
)
So
(
err
,
ShouldNotBeNil
)
})
Convey
(
"from settings"
,
func
()
{
json
:=
`
{
"url": "http://google.com"
}`
settingsJSON
,
_
:=
simplejson
.
NewJson
([]
byte
(
json
))
model
:=
&
m
.
AlertNotification
{
Name
:
"ops"
,
Type
:
"slack"
,
Settings
:
settingsJSON
,
}
not
,
err
:=
NewSlackNotifier
(
model
)
slackNotifier
:=
not
.
(
*
SlackNotifier
)
So
(
err
,
ShouldBeNil
)
So
(
slackNotifier
.
Name
,
ShouldEqual
,
"ops"
)
So
(
slackNotifier
.
Type
,
ShouldEqual
,
"slack"
)
So
(
slackNotifier
.
Url
,
ShouldEqual
,
"http://google.com"
)
So
(
slackNotifier
.
Recipient
,
ShouldEqual
,
""
)
So
(
slackNotifier
.
Mention
,
ShouldEqual
,
""
)
})
Convey
(
"from settings with Recipient and Mention"
,
func
()
{
json
:=
`
{
"url": "http://google.com",
"recipient": "#ds-opentsdb",
"mention": "@carl"
}`
settingsJSON
,
_
:=
simplejson
.
NewJson
([]
byte
(
json
))
model
:=
&
m
.
AlertNotification
{
Name
:
"ops"
,
Type
:
"slack"
,
Settings
:
settingsJSON
,
}
not
,
err
:=
NewSlackNotifier
(
model
)
slackNotifier
:=
not
.
(
*
SlackNotifier
)
So
(
err
,
ShouldBeNil
)
So
(
slackNotifier
.
Name
,
ShouldEqual
,
"ops"
)
So
(
slackNotifier
.
Type
,
ShouldEqual
,
"slack"
)
So
(
slackNotifier
.
Url
,
ShouldEqual
,
"http://google.com"
)
So
(
slackNotifier
.
Recipient
,
ShouldEqual
,
"#ds-opentsdb"
)
So
(
slackNotifier
.
Mention
,
ShouldEqual
,
"@carl"
)
})
})
})
}
pkg/services/alerting/notifiers/webhook_test.go
View file @
dc3a62da
...
...
@@ -40,12 +40,12 @@ func TestWebhookNotifier(t *testing.T) {
}
not
,
err
:=
NewWebHookNotifier
(
model
)
email
Notifier
:=
not
.
(
*
WebhookNotifier
)
webhook
Notifier
:=
not
.
(
*
WebhookNotifier
)
So
(
err
,
ShouldBeNil
)
So
(
email
Notifier
.
Name
,
ShouldEqual
,
"ops"
)
So
(
email
Notifier
.
Type
,
ShouldEqual
,
"email"
)
So
(
email
Notifier
.
Url
,
ShouldEqual
,
"http://google.com"
)
So
(
webhook
Notifier
.
Name
,
ShouldEqual
,
"ops"
)
So
(
webhook
Notifier
.
Type
,
ShouldEqual
,
"email"
)
So
(
webhook
Notifier
.
Url
,
ShouldEqual
,
"http://google.com"
)
})
})
})
...
...
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