mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add test to check that promql.FunctionCalls and parser.Functions contain the same functions
Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
This commit is contained in:
parent
4835bbf376
commit
4124828c00
|
@ -15,11 +15,13 @@ package promql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prometheus/prometheus/pkg/labels"
|
"github.com/prometheus/prometheus/pkg/labels"
|
||||||
"github.com/prometheus/prometheus/pkg/timestamp"
|
"github.com/prometheus/prometheus/pkg/timestamp"
|
||||||
|
"github.com/prometheus/prometheus/promql/parser"
|
||||||
"github.com/prometheus/prometheus/util/teststorage"
|
"github.com/prometheus/prometheus/util/teststorage"
|
||||||
"github.com/prometheus/prometheus/util/testutil"
|
"github.com/prometheus/prometheus/util/testutil"
|
||||||
)
|
)
|
||||||
|
@ -56,3 +58,24 @@ func TestDeriv(t *testing.T) {
|
||||||
testutil.Assert(t, len(vec) == 1, "Expected 1 result, got %d", len(vec))
|
testutil.Assert(t, len(vec) == 1, "Expected 1 result, got %d", len(vec))
|
||||||
testutil.Assert(t, vec[0].V == 0.0, "Expected 0.0 as value, got %f", vec[0].V)
|
testutil.Assert(t, vec[0].V == 0.0, "Expected 0.0 as value, got %f", vec[0].V)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFunctionList(t *testing.T) {
|
||||||
|
// Test that Functions and parser.Functions list the same functions
|
||||||
|
for i := range FunctionCalls {
|
||||||
|
_, ok := parser.Functions[i]
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
panic(fmt.Sprintf("function %s exists in promql package, but not in parser package", i))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range parser.Functions {
|
||||||
|
_, ok := FunctionCalls[i]
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
panic(fmt.Sprintf("function %s exists in promql package, but not in parser package", i))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue