Add test to check that promql.FunctionCalls and parser.Functions contain the same functions
@@ -15,11 +15,13 @@ package promql
import (
"context"
+ "fmt"
"testing"
"time"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp"
+ "github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/util/teststorage"
"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, 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))
+ }
+
+ }
+}
