diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2020-01-24 14:59:36 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2020-01-31 11:33:08 +0100 |
commit | cf606f5c9610df78ae57b516c5415350418633fa (patch) | |
tree | 68e85d8860f28f993ba7258311e16dad3291c891 /document/src/tests | |
parent | c5d747c072f8a94f30e6748737b5f1ad2023dcf0 (diff) |
Propagate configured imported fields to DocumentTypeRepo (C++)
Diffstat (limited to 'document/src/tests')
-rw-r--r-- | document/src/tests/repo/documenttyperepo_test.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/document/src/tests/repo/documenttyperepo_test.cpp b/document/src/tests/repo/documenttyperepo_test.cpp index b263ad75930..0bc80ebcd16 100644 --- a/document/src/tests/repo/documenttyperepo_test.cpp +++ b/document/src/tests/repo/documenttyperepo_test.cpp @@ -532,6 +532,47 @@ TEST("Reference fields are resolved to correct reference type") { EXPECT_EQUAL(*ref1_type, type->getFieldsType().getField("ref3").getDataType()); } +TEST("Config with no imported fields has empty imported fields set in DocumentType") { + DocumenttypesConfigBuilderHelper builder; + builder.document(doc_type_id, type_name, + Struct(header_name), Struct(body_name)); + DocumentTypeRepo repo(builder.config()); + const auto *type = repo.getDocumentType(doc_type_id); + ASSERT_TRUE(type != nullptr); + EXPECT_TRUE(type->imported_field_names().empty()); + EXPECT_FALSE(type->has_imported_field_name("foo")); +} + +TEST("Configured imported field names are available in the DocumentType") { + const int type_2_id = doc_type_id + 1; + // Note: we cheat a bit by specifying imported field names in types that have no + // reference fields. Add to test if we add config read-time validation of this. :) + DocumenttypesConfigBuilderHelper builder; + // Type with one imported field + builder.document(doc_type_id, type_name, + Struct(header_name), Struct(body_name)) + .imported_field("my_cool_field"); + // Type with two imported fields + builder.document(type_2_id, type_name_2, + Struct(header_name_2), Struct(body_name_2)) + .imported_field("my_awesome_field") + .imported_field("my_swag_field"); + + DocumentTypeRepo repo(builder.config()); + const auto* type = repo.getDocumentType(doc_type_id); + ASSERT_TRUE(type != nullptr); + EXPECT_EQUAL(1u, type->imported_field_names().size()); + EXPECT_TRUE(type->has_imported_field_name("my_cool_field")); + EXPECT_FALSE(type->has_imported_field_name("my_awesome_field")); + + type = repo.getDocumentType(type_2_id); + ASSERT_TRUE(type != nullptr); + EXPECT_EQUAL(2u, type->imported_field_names().size()); + EXPECT_TRUE(type->has_imported_field_name("my_awesome_field")); + EXPECT_TRUE(type->has_imported_field_name("my_swag_field")); + EXPECT_FALSE(type->has_imported_field_name("my_cool_field")); +} + namespace { const TensorDataType & |