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
138bee99
Commit
138bee99
authored
Oct 09, 2017
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests
parent
d60339a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
pkg/services/alerting/notifiers/kafka_test.go
+55
-0
No files found.
pkg/services/alerting/notifiers/kafka_test.go
0 → 100644
View file @
138bee99
package
notifiers
import
(
"testing"
"github.com/grafana/grafana/pkg/components/simplejson"
m
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestKafkaNotifier
(
t
*
testing
.
T
)
{
Convey
(
"Kafka 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
:
"kafka_testing"
,
Type
:
"kafka"
,
Settings
:
settingsJSON
,
}
_
,
err
:=
NewKafkaNotifier
(
model
)
So
(
err
,
ShouldNotBeNil
)
})
Convey
(
"settings should send an event to kafka"
,
func
()
{
json
:=
`
{
"kafkaEndpoint": "http://localhost:8082",
"kafkaTopic": "topic1"
}`
settingsJSON
,
_
:=
simplejson
.
NewJson
([]
byte
(
json
))
model
:=
&
m
.
AlertNotification
{
Name
:
"kafka_testing"
,
Type
:
"kafka"
,
Settings
:
settingsJSON
,
}
not
,
err
:=
NewKafkaNotifier
(
model
)
kafkaNotifier
:=
not
.
(
*
KafkaNotifier
)
So
(
err
,
ShouldBeNil
)
So
(
kafkaNotifier
.
Name
,
ShouldEqual
,
"kafka_testing"
)
So
(
kafkaNotifier
.
Type
,
ShouldEqual
,
"kafka"
)
So
(
kafkaNotifier
.
Endpoint
,
ShouldEqual
,
"http://localhost:8082"
)
So
(
kafkaNotifier
.
Topic
,
ShouldEqual
,
"topic1"
)
})
})
})
}
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