-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathfunction_test.go
More file actions
45 lines (38 loc) · 1.05 KB
/
function_test.go
File metadata and controls
45 lines (38 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package setXFilesFactor
import (
"testing"
"time"
"github.com/go-graphite/carbonapi/expr/interfaces"
"github.com/go-graphite/carbonapi/expr/metadata"
"github.com/go-graphite/carbonapi/expr/types"
"github.com/go-graphite/carbonapi/pkg/parser"
th "github.com/go-graphite/carbonapi/tests"
)
var (
md []interfaces.FunctionMetadata = New("")
)
func init() {
for _, m := range md {
metadata.RegisterFunction(m.Name, m.F)
}
}
func TestSetXFilesFactor(t *testing.T) {
now64 := time.Now().Unix()
tests := []th.EvalTestItem{
{
"setXFilesFactor(metric1,0.6)",
map[parser.MetricRequest][]*types.MetricData{
{Metric: "metric1", From: 0, Until: 1}: {types.MakeMetricData("metric1", []float64{1, 2, 3, 4, 5}, 1, now64)},
},
[]*types.MetricData{types.MakeMetricData("metric1",
[]float64{1, 2, 3, 4, 5}, 1, now64).SetXFilesFactor(0.6).SetTag("xFilesFactor", "0.6")},
},
}
for _, tt := range tests {
testName := tt.Target
t.Run(testName, func(t *testing.T) {
eval := th.EvaluatorFromFunc(md[0].F)
th.TestEvalExpr(t, eval, &tt)
})
}
}