From ac6dc0acc9cf1d513de924e418b21e8824dd138b Mon Sep 17 00:00:00 2001 From: msaf1980 Date: Tue, 1 Jun 2021 22:43:18 +0500 Subject: [PATCH] tests: fix aliasByNode deepsource warnings --- expr/functions/aliasByNode/function_test.go | 72 ++++++++++----------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/expr/functions/aliasByNode/function_test.go b/expr/functions/aliasByNode/function_test.go index 20c2e7f2d..c562e9a0f 100644 --- a/expr/functions/aliasByNode/function_test.go +++ b/expr/functions/aliasByNode/function_test.go @@ -44,69 +44,69 @@ func TestAliasByNode(t *testing.T) { 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)}, + Target: "aliasByNode(aliasSub(transformNull(metric1.foo.bar.ba*, 0), 'baz', 'word'), 2, 3)", + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "metric1.foo.bar.ba*", From: 0, Until: 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)}, + Want: []*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{ - {"metric1.foo.bar.baz", 0, 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: "aliasByNode(metric1.foo.bar.baz,1)", + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "metric1.foo.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("foo", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Want: []*types.MetricData{types.MakeMetricData("foo", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - "aliasByNode(metric1.foo.bar.baz,1,3)", - map[parser.MetricRequest][]*types.MetricData{ - {"metric1.foo.bar.baz", 0, 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: "aliasByNode(metric1.foo.bar.baz,1,3)", + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "metric1.foo.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("foo.baz", + Want: []*types.MetricData{types.MakeMetricData("foo.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - "aliasByNode(metric1.foo.bar.baz,1,-2)", - map[parser.MetricRequest][]*types.MetricData{ - {"metric1.foo.bar.baz", 0, 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: "aliasByNode(metric1.foo.bar.baz,1,-2)", + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "metric1.foo.bar.baz", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("foo.bar", + Want: []*types.MetricData{types.MakeMetricData("foo.bar", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - `aliasByTags(*, "foo")`, - map[parser.MetricRequest][]*types.MetricData{ - {"*", 0, 1}: {types.MakeMetricData("metric1.foo.bar.baz;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: `aliasByTags(*, "foo")`, + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("metric1.foo.bar.baz;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("bar", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Want: []*types.MetricData{types.MakeMetricData("bar", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - `aliasByTags(*, "foo", "name")`, - map[parser.MetricRequest][]*types.MetricData{ - {"*", 0, 1}: {types.MakeMetricData("metric1;foo=bar", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: `aliasByTags(*, "foo", "name")`, + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("metric1;foo=bar", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Want: []*types.MetricData{types.MakeMetricData("bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - `aliasByTags(*, 2, "blah", "foo", 1)`, - map[parser.MetricRequest][]*types.MetricData{ - {"*", 0, 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: `aliasByTags(*, 2, "blah", "foo", 1)`, + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData(".bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Want: []*types.MetricData{types.MakeMetricData(".bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - `aliasByTags(*, 2, "baz", "foo", 1)`, - map[parser.MetricRequest][]*types.MetricData{ - {"*", 0, 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: `aliasByTags(*, 2, "baz", "foo", 1)`, + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("bam.bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Want: []*types.MetricData{types.MakeMetricData("bam.bar.metric1", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, { - `aliasByTags(perSecond(*), 'name')`, - map[parser.MetricRequest][]*types.MetricData{ - {"*", 0, 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, + Target: `aliasByTags(perSecond(*), 'name')`, + M: map[parser.MetricRequest][]*types.MetricData{ + {Metric: "*", From: 0, Until: 1}: {types.MakeMetricData("base.metric1;foo=bar;baz=bam", []float64{1, 2, 3, 4, 5}, 1, now32)}, }, - []*types.MetricData{types.MakeMetricData("base.metric1", []float64{math.NaN(), 1, 1, 1, 1}, 1, now32)}, + Want: []*types.MetricData{types.MakeMetricData("base.metric1", []float64{math.NaN(), 1, 1, 1, 1}, 1, now32)}, }, }