@@ -34,6 +34,7 @@ import (
3434 promchunk "github.com/cortexproject/cortex/pkg/chunk/encoding"
3535 "github.com/cortexproject/cortex/pkg/cortexpb"
3636 "github.com/cortexproject/cortex/pkg/ingester/client"
37+ cortexparser "github.com/cortexproject/cortex/pkg/parser"
3738 "github.com/cortexproject/cortex/pkg/querier/batch"
3839 "github.com/cortexproject/cortex/pkg/querier/series"
3940 "github.com/cortexproject/cortex/pkg/util"
@@ -1693,32 +1694,34 @@ func TestConfig_Validate(t *testing.T) {
16931694}
16941695
16951696func Test_EnableExperimentalPromQLFunctions (t * testing.T ) {
1696- EnableExperimentalPromQLFunctions (true , true )
1697+ cortexparser .Setup (true , true )
1698+ defer cortexparser .Setup (false , false )
16971699
1698- // holt_winters function should exist
1699- holtWintersFunc , ok := parser .Functions ["holt_winters" ]
1700- require .True (t , ok )
1700+ // Verify experimental functions flag is set
1701+ require .True (t , parser .EnableExperimentalFunctions )
17011702
17021703 // double_exponential_smoothing function should exist
17031704 doubleExponentialSmoothingFunc , ok := parser .Functions ["double_exponential_smoothing" ]
17041705 require .True (t , ok )
1706+ require .Equal (t , "double_exponential_smoothing" , doubleExponentialSmoothingFunc .Name )
1707+ require .True (t , parser .Functions ["double_exponential_smoothing" ].Experimental )
17051708
1706- // holt_winters should not experimental function.
1709+ // holt_winters should exist
1710+ holtWintersFunc , ok := parser .Functions ["holt_winters" ]
1711+ require .True (t , ok )
1712+ require .Equal (t , "holt_winters" , holtWintersFunc .Name )
17071713 require .False (t , holtWintersFunc .Experimental )
1708- // holt_winters's Variadic, ReturnType, and ArgTypes are the same as the double_exponential_smoothing.
1714+
1715+ // holt_winters's Variadic, ReturnType, and ArgTypes are the same as the double_exponential_smoothing
17091716 require .Equal (t , doubleExponentialSmoothingFunc .Variadic , holtWintersFunc .Variadic )
17101717 require .Equal (t , doubleExponentialSmoothingFunc .ReturnType , holtWintersFunc .ReturnType )
17111718 require .Equal (t , doubleExponentialSmoothingFunc .ArgTypes , holtWintersFunc .ArgTypes )
17121719
1713- // double_exponential_smoothing shouldn't be changed.
1714- require .Equal (t , "double_exponential_smoothing" , doubleExponentialSmoothingFunc .Name )
1715- require .True (t , parser .Functions ["double_exponential_smoothing" ].Experimental )
1716-
1717- // holt_winters function calls should exist.
1720+ // holt_winters function calls should exist
17181721 _ , ok = promql .FunctionCalls ["holt_winters" ]
17191722 require .True (t , ok )
17201723
1721- // double_exponential_smoothing function calls should exist.
1724+ // double_exponential_smoothing function calls should exist
17221725 _ , ok = promql .FunctionCalls ["double_exponential_smoothing" ]
17231726 require .True (t , ok )
17241727}
0 commit comments