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
f2436fc7
Commit
f2436fc7
authored
Aug 10, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(alerting): add tests for simple reducer
parent
4fd8b2ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
15 deletions
+33
-15
pkg/services/alerting/conditions/reducer_test.go
+33
-0
pkg/services/alerting/evaluator.go
+0
-15
No files found.
pkg/services/alerting/conditions/reducer_test.go
0 → 100644
View file @
f2436fc7
package
conditions
import
(
"testing"
"github.com/grafana/grafana/pkg/tsdb"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestSimpleReducer
(
t
*
testing
.
T
)
{
Convey
(
"Test simple reducer"
,
t
,
func
()
{
Convey
(
"can calculate avg of time serie"
,
func
()
{
result
:=
testReducer
(
"avg"
,
1
,
2
,
3
)
So
(
result
,
ShouldEqual
,
float64
(
2
))
})
})
}
func
testReducer
(
typ
string
,
datapoints
...
float64
)
float64
{
reducer
:=
NewSimpleReducer
(
typ
)
var
timeserie
[][
2
]
float64
dummieTimestamp
:=
float64
(
521452145
)
for
_
,
v
:=
range
datapoints
{
timeserie
=
append
(
timeserie
,
[
2
]
float64
{
v
,
dummieTimestamp
})
}
tsdb
:=
&
tsdb
.
TimeSeries
{
Name
:
"test time serie"
,
Points
:
timeserie
,
}
return
reducer
.
Reduce
(
tsdb
)
}
pkg/services/alerting/evaluator.go
deleted
100644 → 0
View file @
4fd8b2ac
package
alerting
type
compareFn
func
(
float64
,
float64
)
bool
func
evalCondition
(
level
Level
,
result
float64
)
bool
{
return
operators
[
level
.
Operator
](
result
,
level
.
Value
)
}
var
operators
=
map
[
string
]
compareFn
{
">"
:
func
(
num1
,
num2
float64
)
bool
{
return
num1
>
num2
},
">="
:
func
(
num1
,
num2
float64
)
bool
{
return
num1
>=
num2
},
"<"
:
func
(
num1
,
num2
float64
)
bool
{
return
num1
<
num2
},
"<="
:
func
(
num1
,
num2
float64
)
bool
{
return
num1
<=
num2
},
""
:
func
(
num1
,
num2
float64
)
bool
{
return
false
},
}
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