summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@vespa.ai>2023-09-27 17:48:06 +0200
committerJon Bratseth <bratseth@vespa.ai>2023-09-27 17:48:06 +0200
commitae414aab08a848ae1cf1539a680ce17f4b429afc (patch)
treee66a51adf576df44ac9d86182b54099c28bc39a9 /config-model
parent9e1fd455fb3bd911bd6183c42e3d513c3f6278af (diff)
Simplify tests
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/test/examples/indexing_modify_field_no_output.sd8
-rw-r--r--config-model/src/test/java/com/yahoo/schema/parser/SchemaParserTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/IndexingValuesTestCase.java43
3 files changed, 37 insertions, 15 deletions
diff --git a/config-model/src/test/examples/indexing_modify_field_no_output.sd b/config-model/src/test/examples/indexing_modify_field_no_output.sd
deleted file mode 100644
index ac2bed520e8..00000000000
--- a/config-model/src/test/examples/indexing_modify_field_no_output.sd
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-search indexing_modify_field_no_output {
- document indexing_modify_field_no_output {
- field foo type string {
- indexing: lowercase | echo
- }
- }
-}
diff --git a/config-model/src/test/java/com/yahoo/schema/parser/SchemaParserTestCase.java b/config-model/src/test/java/com/yahoo/schema/parser/SchemaParserTestCase.java
index e69f26a31c9..89eff4ec464 100644
--- a/config-model/src/test/java/com/yahoo/schema/parser/SchemaParserTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/parser/SchemaParserTestCase.java
@@ -269,7 +269,6 @@ public class SchemaParserTestCase {
checkFileParses("src/test/examples/implicitsummaryfields.sd");
checkFileParses("src/test/examples/incorrectrankingexpressionfileref.sd");
checkFileParses("src/test/examples/indexing_extra.sd");
- checkFileParses("src/test/examples/indexing_modify_field_no_output.sd");
checkFileParses("src/test/examples/indexing.sd");
checkFileParses("src/test/examples/indexrewrite.sd");
checkFileParses("src/test/examples/indexsettings.sd");
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/IndexingValuesTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/IndexingValuesTestCase.java
index 1f723924db6..2fa02cc3744 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/IndexingValuesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/IndexingValuesTestCase.java
@@ -1,13 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.processing;
+import com.yahoo.schema.ApplicationBuilder;
import com.yahoo.schema.parser.ParseException;
+import com.yahoo.yolean.Exceptions;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static com.yahoo.schema.processing.AssertSearchBuilder.assertBuildFails;
import static com.yahoo.schema.processing.AssertSearchBuilder.assertBuilds;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
@@ -15,16 +19,43 @@ import static com.yahoo.schema.processing.AssertSearchBuilder.assertBuilds;
public class IndexingValuesTestCase {
@Test
- void requireThatModifyFieldNoOutputDoesNotThrow() throws IOException, ParseException {
- assertBuilds("src/test/examples/indexing_modify_field_no_output.sd");
+ void requireThatModifyFieldNoOutputDoesNotThrow() throws ParseException {
+ var schema = """
+ search indexing_modify_field_no_output {
+ document indexing_modify_field_no_output {
+ field foo type string {
+ indexing: lowercase | echo
+ }
+ }
+ }
+ """;
+ ApplicationBuilder.createFromString(schema);
}
@Test
void requireThatInputOtherFieldThrows() throws IOException, ParseException {
- assertBuildFails("src/test/examples/indexing_input_other_field.sd",
- "For schema 'indexing_input_other_field', field 'bar': Indexing expression 'input foo' " +
- "attempts to modify the value of the document field 'bar'. " +
- "Use a field outside the document block instead.");
+ try {
+ var schema = """
+ search indexing_input_other_field {
+ document indexing_input_other_field {
+ field foo type string {
+
+ }
+ field bar type string {
+ indexing: input foo | attribute | index | summary
+ }
+ }
+ }
+ """;
+ ApplicationBuilder.createFromString(schema);
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("For schema 'indexing_input_other_field', field 'bar': Indexing expression 'input foo' " +
+ "attempts to modify the value of the document field 'bar'. " +
+ "Use a field outside the document block instead.",
+ Exceptions.toMessageString(e));
+ }
}
}