Skip to content

Commit

Permalink
tests: aliasByNode strip function in name
Browse files Browse the repository at this point in the history
  • Loading branch information
msaf1980 authored and Civil committed Jun 1, 2021
1 parent 1b8979b commit 12c2b80
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions expr/functions/aliasByNode/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ import (
"github.com/go-graphite/carbonapi/pkg/parser"
th "github.com/go-graphite/carbonapi/tests"

"github.com/go-graphite/carbonapi/expr/functions/aliasSub"
"github.com/go-graphite/carbonapi/expr/functions/perSecond"
"github.com/go-graphite/carbonapi/expr/functions/transformNull"
)

func init() {
md := New("")
for _, m := range md {
metadata.RegisterFunction(m.Name, m.F)
}
asFunc := aliasSub.New("")
for _, m := range asFunc {
metadata.RegisterFunction(m.Name, m.F)
}
tnFunc := transformNull.New("")
for _, m := range tnFunc {
metadata.RegisterFunction(m.Name, m.F)
}
psFunc := perSecond.New("")
for _, m := range psFunc {
metadata.RegisterFunction(m.Name, m.F)
Expand All @@ -33,6 +43,13 @@ func TestAliasByNode(t *testing.T) {
now32 := int64(time.Now().Unix())

tests := []th.EvalTestItem{
{
"aliasByNode(aliasSub(transformNull(metric1.foo.bar.ba*, 0), 'baz', 'word'), 2, 3)",
map[parser.MetricRequest][]*types.MetricData{
{"metric1.foo.bar.ba*", 0, 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)},
},
[]*types.MetricData{types.MakeMetricData("bar.word", []float64{1, 2, 3, 4, 5}, 1, now32)},
},
{
"aliasByNode(metric1.foo.bar.baz,1)",
map[parser.MetricRequest][]*types.MetricData{
Expand Down

0 comments on commit 12c2b80

Please sign in to comment.