Skip to content

Commit

Permalink
Add one more test for +up
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Raskin committed May 24, 2019
1 parent 4484c92 commit 4d90fd3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/query/parser/promql/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestInvalidOffset(t *testing.T) {
require.Error(t, err)
}

func TestUnary(t *testing.T) {
func TestNegativeUnary(t *testing.T) {
q := "-up"
p, err := Parse(q, models.NewTagOptions())
require.NoError(t, err)
Expand All @@ -93,6 +93,18 @@ func TestUnary(t *testing.T) {
assert.Equal(t, edges[0].ChildID, parser.NodeID("1"))
}

func TestPositiveUnary(t *testing.T) {
q := "+up"
p, err := Parse(q, models.NewTagOptions())
require.NoError(t, err)
transforms, edges, err := p.DAG()
require.NoError(t, err)
assert.Len(t, transforms, 1) // "+" defaults to just a fetch operation
assert.Equal(t, transforms[0].Op.OpType(), functions.FetchType)
assert.Equal(t, transforms[0].ID, parser.NodeID("0"))
assert.Len(t, edges, 0)
}

func TestInvalidUnary(t *testing.T) {
q := "*up"
_, err := Parse(q, models.NewTagOptions())
Expand Down
1 change: 0 additions & 1 deletion src/query/parser/promql/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ func NewFunctionExpr(
return p, true, err

default:
// TODO: handle other types.
return nil, false, fmt.Errorf("function not supported: %s", name)
}
}
Expand Down

0 comments on commit 4d90fd3

Please sign in to comment.