github.com/go-graphite/carbonapi@v0.17.0/expr/functions/setXFilesFactor/function_test.go (about) 1 package setXFilesFactor 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/go-graphite/carbonapi/expr/interfaces" 8 "github.com/go-graphite/carbonapi/expr/metadata" 9 "github.com/go-graphite/carbonapi/expr/types" 10 "github.com/go-graphite/carbonapi/pkg/parser" 11 th "github.com/go-graphite/carbonapi/tests" 12 ) 13 14 var ( 15 md []interfaces.FunctionMetadata = New("") 16 ) 17 18 func init() { 19 for _, m := range md { 20 metadata.RegisterFunction(m.Name, m.F) 21 } 22 } 23 24 func TestSetXFilesFactor(t *testing.T) { 25 now64 := time.Now().Unix() 26 27 tests := []th.EvalTestItem{ 28 { 29 "setXFilesFactor(metric1,0.6)", 30 map[parser.MetricRequest][]*types.MetricData{ 31 {Metric: "metric1", From: 0, Until: 1}: {types.MakeMetricData("metric1", []float64{1, 2, 3, 4, 5}, 1, now64)}, 32 }, 33 []*types.MetricData{types.MakeMetricData("metric1", 34 []float64{1, 2, 3, 4, 5}, 1, now64).SetXFilesFactor(0.6).SetTag("xFilesFactor", "0.6")}, 35 }, 36 } 37 38 for _, tt := range tests { 39 testName := tt.Target 40 t.Run(testName, func(t *testing.T) { 41 eval := th.EvaluatorFromFunc(md[0].F) 42 th.TestEvalExpr(t, eval, &tt) 43 }) 44 } 45 }