diff options
Diffstat (limited to 'searchcommon/src/tests/schema')
-rw-r--r-- | searchcommon/src/tests/schema/imported-fields-cfg/imported-fields.cfg | 7 | ||||
-rw-r--r-- | searchcommon/src/tests/schema/load-save-cfg/attributes.cfg (renamed from searchcommon/src/tests/schema/attributes.cfg) | 0 | ||||
-rw-r--r-- | searchcommon/src/tests/schema/load-save-cfg/indexschema.cfg (renamed from searchcommon/src/tests/schema/indexschema.cfg) | 0 | ||||
-rw-r--r-- | searchcommon/src/tests/schema/load-save-cfg/summary.cfg (renamed from searchcommon/src/tests/schema/summary.cfg) | 0 | ||||
-rw-r--r-- | searchcommon/src/tests/schema/schema_test.cpp | 21 |
5 files changed, 22 insertions, 6 deletions
diff --git a/searchcommon/src/tests/schema/imported-fields-cfg/imported-fields.cfg b/searchcommon/src/tests/schema/imported-fields-cfg/imported-fields.cfg new file mode 100644 index 00000000000..ccfec672134 --- /dev/null +++ b/searchcommon/src/tests/schema/imported-fields-cfg/imported-fields.cfg @@ -0,0 +1,7 @@ +attribute[2] +attribute[0].name imported_a +attribute[0].referencefield ref_a +attribute[0].targetfield target_a +attribute[1].name imported_b +attribute[1].referencefield ref_b +attribute[1].targetfield target_b diff --git a/searchcommon/src/tests/schema/attributes.cfg b/searchcommon/src/tests/schema/load-save-cfg/attributes.cfg index 09f711b6a65..09f711b6a65 100644 --- a/searchcommon/src/tests/schema/attributes.cfg +++ b/searchcommon/src/tests/schema/load-save-cfg/attributes.cfg diff --git a/searchcommon/src/tests/schema/indexschema.cfg b/searchcommon/src/tests/schema/load-save-cfg/indexschema.cfg index 989f30f7499..989f30f7499 100644 --- a/searchcommon/src/tests/schema/indexschema.cfg +++ b/searchcommon/src/tests/schema/load-save-cfg/indexschema.cfg diff --git a/searchcommon/src/tests/schema/summary.cfg b/searchcommon/src/tests/schema/load-save-cfg/summary.cfg index 0c2de33d076..0c2de33d076 100644 --- a/searchcommon/src/tests/schema/summary.cfg +++ b/searchcommon/src/tests/schema/load-save-cfg/summary.cfg diff --git a/searchcommon/src/tests/schema/schema_test.cpp b/searchcommon/src/tests/schema/schema_test.cpp index 142a5f25184..f399215dbda 100644 --- a/searchcommon/src/tests/schema/schema_test.cpp +++ b/searchcommon/src/tests/schema/schema_test.cpp @@ -13,6 +13,8 @@ using vespalib::string; namespace search { namespace index { +using SIAF = Schema::ImportedAttributeField; + void assertField(const Schema::Field & exp, const Schema::Field & act) { EXPECT_EQUAL(exp.getName(), act.getName()); EXPECT_EQUAL(exp.getDataType(), act.getDataType()); @@ -84,7 +86,7 @@ TEST("testBasic") { s.addFieldSet(Schema::FieldSet("default").addField("foo").addField("bar")); - s.addImportedAttributeField(Schema::ImportedAttributeField("imported", schema::INT32)); + s.addImportedAttributeField(SIAF("imported", schema::INT32)); EXPECT_EQUAL(2u, s.getNumIndexFields()); { @@ -157,9 +159,7 @@ TEST("testBasic") { { const auto &imported = s.getImportedAttributeFields(); EXPECT_EQUAL(1u, imported.size()); - EXPECT_EQUAL("imported", imported[0].getName()); - EXPECT_EQUAL(schema::INT32, imported[0].getDataType()); - EXPECT_EQUAL(schema::SINGLE, imported[0].getCollectionType()); + TEST_DO(assertField(SIAF("imported", schema::INT32, schema::SINGLE), imported[0])); } } @@ -167,14 +167,13 @@ TEST("testLoadAndSave") { using SIF = Schema::IndexField; using SAF = Schema::AttributeField; using SSF = Schema::SummaryField; - using SIAF = Schema::ImportedAttributeField; using SDT = schema::DataType; using SCT = schema::CollectionType; typedef Schema::FieldSet SFS; { // load from config -> save to file -> load from file Schema s; - SchemaConfigurer configurer(s, "dir:" + TEST_PATH("")); + SchemaConfigurer configurer(s, "dir:" + TEST_PATH("load-save-cfg")); EXPECT_EQUAL(3u, s.getNumIndexFields()); assertIndexField(SIF("a", SDT::STRING), s.getIndexField(0)); assertIndexField(SIF("b", SDT::INT64), s.getIndexField(1)); @@ -411,6 +410,16 @@ TEST("require that imported attribute fields are not saved to disk") } } +TEST("require that schema can be built from imported-fields config") +{ + Schema s; + SchemaConfigurer configurer(s, "dir:" + TEST_PATH("imported-fields-cfg")); + const auto &imported = s.getImportedAttributeFields(); + EXPECT_EQUAL(2u, imported.size()); + TEST_DO(assertField(SIAF("imported_a", schema::STRING, schema::SINGLE), imported[0])); + TEST_DO(assertField(SIAF("imported_b", schema::STRING, schema::SINGLE), imported[1])); +} + } // namespace index } // namespace search |