diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-27 12:39:13 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-27 12:39:13 +0200 |
commit | 844ed003049e34eff81ca0631376e6db3fd51e66 (patch) | |
tree | c429b4f62bd4c7dea5e346a6e3a6c3523751c636 /config-model/src/test | |
parent | 258d329a753206fc31b9680e868539292b4f5d23 (diff) |
Small test are better to keep in the code.
Diffstat (limited to 'config-model/src/test')
6 files changed, 45 insertions, 67 deletions
diff --git a/config-model/src/test/examples/duplicatenamesindoc.sd b/config-model/src/test/examples/duplicatenamesindoc.sd deleted file mode 100644 index 3c55efe953d..00000000000 --- a/config-model/src/test/examples/duplicatenamesindoc.sd +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -search duplicatenamesindoc { -document { - field foo type int { - indexing: attribute - } - - field fOo type string { - indexing: index - } -} -} diff --git a/config-model/src/test/examples/duplicatenamesinsearchdifferenttype.sd b/config-model/src/test/examples/duplicatenamesinsearchdifferenttype.sd deleted file mode 100644 index 502a4bb7aff..00000000000 --- a/config-model/src/test/examples/duplicatenamesinsearchdifferenttype.sd +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -search duplicatenamesinsearch { -document { - field grpphotoids64 type string { } -} - -field grpphotoids64 type array<long> { - indexing: input grpphotoids64 | split " " | for_each { - base64decode } | attribute - } - -} diff --git a/config-model/src/test/examples/incorrectsummarytypes.sd b/config-model/src/test/examples/incorrectsummarytypes.sd deleted file mode 100644 index 9304ad5ca20..00000000000 --- a/config-model/src/test/examples/incorrectsummarytypes.sd +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -search incorrectsummarytypes { - - document incorrectsummarytypes { - - field somestring type string { - indexing: summary - } - - } - - document-summary incorrect { - - summary somestring type int { - } - - } - -} diff --git a/config-model/src/test/examples/name-check.sd b/config-model/src/test/examples/name-check.sd deleted file mode 100644 index bd7c0713e3a..00000000000 --- a/config-model/src/test/examples/name-check.sd +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -# An entry-level configuration. -# You can get a reasonable configuration by only configuring -# a document -search simple { - - document name-check { - - field title type string { - indexing: summary | index - } - - # reserved name, should trigger error - field sddocname type string { - indexing: index - } - - } - -} diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java index f11799495a2..627394bb6ea 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java @@ -17,7 +17,18 @@ public class IncorrectSummaryTypesTestCase extends SearchDefinitionTestCase { @Test public void testImportingIncorrect() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/incorrectsummarytypes.sd"); + SearchBuilder.createFromString( + "search incorrectsummarytypes {\n" + + " document incorrectsummarytypes {\n" + + " field somestring type string {\n" + + " indexing: summary\n" + + " }\n" + + " }\n" + + " document-summary incorrect {\n" + + " summary somestring type int {\n" + + " }\n" + + " }\n" + + "}\n"); fail("processing should have failed"); } catch (RuntimeException e) { assertEquals("'summary somestring type string' in 'destinations(default )' is inconsistent with 'summary somestring type int' in 'destinations(incorrect )': All declarations of the same summary field must have the same type", e.getMessage()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java index c19244a4bf2..b539c65150d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java @@ -22,7 +22,18 @@ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { @Test public void testNameField() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/name-check.sd"); + SearchBuilder.createFromString( + "search simple {\n" + + " document name-check {\n" + + " field title type string {\n" + + " indexing: summary | index\n" + + " }\n" + + " # reserved name, should trigger error\n" + + " field sddocname type string {\n" + + " indexing: index\n" + + " }\n" + + " }\n" + + "}"); fail("Should throw exception."); } catch (Exception expected) { // Success @@ -32,7 +43,16 @@ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { @Test public void testDuplicateNamesInSearchDifferentType() { try { - SearchBuilder.buildFromFile("src/test/examples/duplicatenamesinsearchdifferenttype.sd"); + SearchBuilder.createFromString( + "search duplicatenamesinsearch {\n" + + " document {\n" + + " field grpphotoids64 type string { }\n" + + " }\n" + + " field grpphotoids64 type array<long> {\n" + + " indexing: input grpphotoids64 | split \" \" | for_each {\n" + + " base64decode } | attribute\n" + + " }\n" + + "}"); fail("Should throw exception."); } catch (Exception e) { assertEquals("For search 'duplicatenamesinsearch', field 'grpphotoids64': Incompatible types. Expected Array<long> for index field 'grpphotoids64', got string.", e.getMessage()); @@ -42,7 +62,17 @@ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { @Test public void testDuplicateNamesInDoc() { try { - SearchBuilder.buildFromFile("src/test/examples/duplicatenamesindoc.sd"); + SearchBuilder.createFromString( + "search duplicatenamesindoc {\n" + + " document {\n" + + " field foo type int {\n" + + " indexing: attribute\n" + + " }\n" + + " field fOo type string {\n" + + " indexing: index\n" + + " }\n" + + " }\n" + + "}"); fail("Should throw exception."); } catch (Exception e) { assertTrue(e.getMessage().matches(".*Duplicate.*")); |