Skip to content

Commit 2713280

Browse files
committed
Fix configuration and source matching in random tests
1 parent d794329 commit 2713280

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/TestCaseSupplier.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,18 +1797,24 @@ public Object extra() {
17971797

17981798
/**
17991799
* Build a new {@link TestCase} with the {@link #TEST_CONFIGURATION}.
1800+
* <p>
1801+
* The source is also set to match the configuration
1802+
* </p>
18001803
*
18011804
* @deprecated Use a custom configuration instead, and test the results.
18021805
*/
18031806
@Deprecated
18041807
public TestCase withStaticConfiguration() {
1805-
return withConfiguration(TEST_CONFIGURATION);
1808+
return withConfiguration(TEST_SOURCE, TEST_CONFIGURATION);
18061809
}
18071810

18081811
/**
18091812
* Build a new {@link TestCase} with new {@link #configuration}.
1813+
* <p>
1814+
* As the configuration query should match the source, the source is also updated here.
1815+
* </p>
18101816
*/
1811-
public TestCase withConfiguration(Configuration configuration) {
1817+
public TestCase withConfiguration(Source source, Configuration configuration) {
18121818
return new TestCase(
18131819
source,
18141820
configuration,

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AbstractConfigurationFunctionTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected Expression build(Source source, List<Expression> args) {
2929
public void testSerializationWithConfiguration() {
3030
assumeTrue("can't serialize function", canSerialize());
3131

32-
Configuration config = randomConfiguration();
32+
Configuration config = randomConfiguration(testCase.getSource().text(), randomTables());
3333
Expression expr = buildWithConfiguration(testCase.getSource(), testCase.getDataAsFields(), config);
3434

3535
assertSerialization(expr, config);

0 commit comments

Comments
 (0)