Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 committed Nov 1, 2024
1 parent 7807025 commit 285e8aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 1 addition & 3 deletions walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,7 @@ func getOutputSeries(expr parser.Expr) ([]labels.Labels, bool) {
if !node.Without {
for _, lbl := range lbls {
for _, groupLabel := range node.Grouping {
if val := lbl.Get(groupLabel); val == "" {
continue
} else {
if val := lbl.Get(groupLabel); val != "" {
lb.Set(groupLabel, val)
}
}
Expand Down
20 changes: 10 additions & 10 deletions walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,29 @@ func TestWalkAggregateParam(t *testing.T) {
p := New(rnd, testSeriesSet, opts...)
for i, tc := range []struct {
op parser.ItemType
expectedFunc func(expr parser.Expr)
expectedFunc func(t *testing.T, expr parser.Expr)
}{
{
op: parser.TOPK,
expectedFunc: func(expr parser.Expr) {
expectedFunc: func(t *testing.T, expr parser.Expr) {
require.Equal(t, parser.ValueTypeScalar, expr.Type())
},
},
{
op: parser.BOTTOMK,
expectedFunc: func(expr parser.Expr) {
expectedFunc: func(t *testing.T, expr parser.Expr) {
require.Equal(t, parser.ValueTypeScalar, expr.Type())
},
},
{
op: parser.QUANTILE,
expectedFunc: func(expr parser.Expr) {
expectedFunc: func(t *testing.T, expr parser.Expr) {
require.Equal(t, parser.ValueTypeScalar, expr.Type())
},
},
{
op: parser.COUNT_VALUES,
expectedFunc: func(expr parser.Expr) {
expectedFunc: func(t *testing.T, expr parser.Expr) {
e, ok := expr.(*parser.StringLiteral)
require.True(t, ok)
require.Equal(t, e.Val, "value")
Expand All @@ -219,7 +219,7 @@ func TestWalkAggregateParam(t *testing.T) {
} {
t.Run(fmt.Sprintf("test_case_%d", i), func(t *testing.T) {
expr := p.walkAggregateParam(tc.op)
tc.expectedFunc(expr)
tc.expectedFunc(t, expr)
})
}
}
Expand Down Expand Up @@ -311,18 +311,18 @@ func TestWalkBinaryOp(t *testing.T) {
p := New(rnd, testSeriesSet, opts...)
for i, tc := range []struct {
disallowVector bool
expectedFunc func(op parser.ItemType)
expectedFunc func(t *testing.T, op parser.ItemType)
}{
{
disallowVector: true,
expectedFunc: func(op parser.ItemType) {
expectedFunc: func(t *testing.T, op parser.ItemType) {
require.True(t, !op.IsSetOperator())
},
},
} {
t.Run(fmt.Sprintf("test_case_%d", i), func(t *testing.T) {
op := p.walkBinaryOp(tc.disallowVector)
tc.expectedFunc(op)
tc.expectedFunc(t, op)
})
}
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func TestWalkUnaryExpr(t *testing.T) {
}{
{
valueTypes: []parser.ValueType{},
expectedFunc: func(u *parser.UnaryExpr) {},
expectedFunc: func(_ *parser.UnaryExpr) {},
},
{
valueTypes: []parser.ValueType{parser.ValueTypeScalar},
Expand Down

0 comments on commit 285e8aa

Please sign in to comment.