From 1dbd799354504d3b943ba3e68e70822c9cbb4e35 Mon Sep 17 00:00:00 2001 From: Tobias Guggenmos Date: Fri, 6 Mar 2020 09:17:01 +0100 Subject: [PATCH] PromQL: Fix regression tests (#6935) This PR fixes the regression tests for the issue fixed in #6931 . The reason for that is that all of the invalid queries that triggered the regression have become more or less valid syntax in #6933 (they might still fail typechecking). Signed-off-by: Tobias Guggenmos --- promql/parser/parse_test.go | 51 ++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/promql/parser/parse_test.go b/promql/parser/parse_test.go index e161d9543..8de42dfdc 100644 --- a/promql/parser/parse_test.go +++ b/promql/parser/parse_test.go @@ -2167,15 +2167,52 @@ var testExpr = []struct { }, { input: "rate(avg)", fail: true, - errMsg: `unexpected ")"`, + errMsg: `expected type range vector`, }, { - input: "sum(sum)", - fail: true, - errMsg: `unexpected ")"`, + input: "sum(sum)", + expected: &AggregateExpr{ + Op: SUM, + Expr: &VectorSelector{ + Name: "sum", + LabelMatchers: []*labels.Matcher{ + mustLabelMatcher(labels.MatchEqual, string(model.MetricNameLabel), "sum"), + }, + PosRange: PositionRange{ + Start: 4, + End: 7, + }, + }, + PosRange: PositionRange{ + Start: 0, + End: 8, + }, + }, }, { - input: "a + sum", - fail: true, - errMsg: `unexpected end of input`, + input: "a + sum", + expected: &BinaryExpr{ + Op: ADD, + LHS: &VectorSelector{ + Name: "a", + LabelMatchers: []*labels.Matcher{ + mustLabelMatcher(labels.MatchEqual, string(model.MetricNameLabel), "a"), + }, + PosRange: PositionRange{ + Start: 0, + End: 1, + }, + }, + RHS: &VectorSelector{ + Name: "sum", + LabelMatchers: []*labels.Matcher{ + mustLabelMatcher(labels.MatchEqual, string(model.MetricNameLabel), "sum"), + }, + PosRange: PositionRange{ + Start: 4, + End: 7, + }, + }, + VectorMatching: &VectorMatching{}, + }, }, // String quoting and escape sequence interpretation tests. {