(t *testing.T)
| 742 | } |
| 743 | |
| 744 | func TestScalarExpressionOperators(t *testing.T) { |
| 745 | tests := []struct { |
| 746 | in string |
| 747 | expected ScalarFilter |
| 748 | expectedStr string |
| 749 | }{ |
| 750 | {in: "count() > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateCount, nil), NewStaticInt(1)), expectedStr: "(count()) > 1"}, |
| 751 | {in: "max(.a) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateMax, NewAttribute("a")), NewStaticInt(1)), expectedStr: "(max(.a)) > 1"}, |
| 752 | {in: "min(1) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateMin, NewStaticInt(1)), NewStaticInt(1)), expectedStr: "(min(1)) > 1"}, |
| 753 | {in: "sum(true) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateSum, NewStaticBool(true)), NewStaticInt(1)), expectedStr: "(sum(true)) > 1"}, |
| 754 | {in: "avg(`c`) > 1", expected: newScalarFilter(OpGreater, newAggregate(aggregateAvg, NewStaticString("c")), NewStaticInt(1)), expectedStr: "(avg(`c`)) > 1"}, |
| 755 | } |
| 756 | |
| 757 | for _, tc := range tests { |
| 758 | t.Run(tc.in, func(t *testing.T) { |
| 759 | actual, err := Parse(tc.in) |
| 760 | |
| 761 | require.NoError(t, err) |
| 762 | require.Equal(t, newRootExpr(newPipeline(tc.expected)), actual) |
| 763 | require.Equal(t, tc.expectedStr, actual.String()) |
| 764 | }) |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | func TestSpansetFilterErrors(t *testing.T) { |
| 769 | tests := []struct { |
nothing calls this directly
no test coverage detected