Skip to content

Commit

Permalink
tests: fix aliasByNode deepsource warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
msaf1980 authored and Civil committed Jun 1, 2021
1 parent c03b5f5 commit ac6dc0a
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions expr/functions/aliasByNode/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
},
}

Expand Down

0 comments on commit ac6dc0a

Please sign in to comment.