mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 14:27:27 -08:00
Prettifier: Add spaces with non-callable keywords (#11005)
* Prettifier: Add spaces with non-callable keywords I prefer to have a difference between, on one side: functions calls, end(), start(), and on the other side with, without, ignoring, by and group_rrigt, group_left. The reasoning is that the former ones are not calls, while other are functions. Additionally, it matches the examples in our documentation. Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu> * Fix tests Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
parent
ce1bf8b15a
commit
d41e5a5582
|
@ -184,10 +184,12 @@ func TestBinaryExprPretty(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, test := range inputs {
|
||||
t.Run(test.in, func(t *testing.T) {
|
||||
expr, err := ParseExpr(test.in)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, test.out, Prettify(expr))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,8 +661,10 @@ func TestUnaryPretty(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for _, test := range inputs {
|
||||
t.Run(test.in, func(t *testing.T) {
|
||||
expr, err := ParseExpr(test.in)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, test.out, Prettify(expr))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,15 @@ func TestExprString(t *testing.T) {
|
|||
},
|
||||
{
|
||||
in: `sum by(code) (task:errors:rate10s{job="s"})`,
|
||||
out: `sum by (code) (task:errors:rate10s{job="s"})`,
|
||||
},
|
||||
{
|
||||
in: `sum without() (task:errors:rate10s{job="s"})`,
|
||||
out: `sum without () (task:errors:rate10s{job="s"})`,
|
||||
},
|
||||
{
|
||||
in: `sum without(instance) (task:errors:rate10s{job="s"})`,
|
||||
out: `sum without (instance) (task:errors:rate10s{job="s"})`,
|
||||
},
|
||||
{
|
||||
in: `topk(5, task:errors:rate10s{job="s"})`,
|
||||
|
@ -49,15 +52,19 @@ func TestExprString(t *testing.T) {
|
|||
},
|
||||
{
|
||||
in: `a - on() c`,
|
||||
out: `a - on () c`,
|
||||
},
|
||||
{
|
||||
in: `a - on(b) c`,
|
||||
out: `a - on (b) c`,
|
||||
},
|
||||
{
|
||||
in: `a - on(b) group_left(x) c`,
|
||||
out: `a - on (b) group_left (x) c`,
|
||||
},
|
||||
{
|
||||
in: `a - on(b) group_left(x, y) c`,
|
||||
out: `a - on (b) group_left (x, y) c`,
|
||||
},
|
||||
{
|
||||
in: `a - on(b) group_left c`,
|
||||
|
@ -65,9 +72,11 @@ func TestExprString(t *testing.T) {
|
|||
},
|
||||
{
|
||||
in: `a - on(b) group_left() (c)`,
|
||||
out: `a - on (b) group_left () (c)`,
|
||||
},
|
||||
{
|
||||
in: `a - ignoring(b) c`,
|
||||
out: `a - ignoring (b) c`,
|
||||
},
|
||||
{
|
||||
in: `a - ignoring() c`,
|
||||
|
|
Loading…
Reference in a new issue