aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'document/src/tests')
-rw-r--r--document/src/tests/document_type_repo_factory/CMakeLists.txt10
-rw-r--r--document/src/tests/document_type_repo_factory/document_type_repo_factory_test.cpp52
-rw-r--r--document/src/tests/documentselectparsertest.cpp2
-rw-r--r--document/src/tests/fieldpathupdatetestcase.cpp2
4 files changed, 64 insertions, 2 deletions
diff --git a/document/src/tests/document_type_repo_factory/CMakeLists.txt b/document/src/tests/document_type_repo_factory/CMakeLists.txt
new file mode 100644
index 00000000000..c872559c3b5
--- /dev/null
+++ b/document/src/tests/document_type_repo_factory/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(document_document_type_repo_factory_test_app TEST
+ SOURCES
+ document_type_repo_factory_test.cpp
+ DEPENDS
+ document
+ AFTER
+ document_documentconfig
+)
+vespa_add_test(NAME document_document_type_repo_factory_test_app COMMAND document_document_type_repo_factory_test_app)
diff --git a/document/src/tests/document_type_repo_factory/document_type_repo_factory_test.cpp b/document/src/tests/document_type_repo_factory/document_type_repo_factory_test.cpp
new file mode 100644
index 00000000000..2cd10225edd
--- /dev/null
+++ b/document/src/tests/document_type_repo_factory/document_type_repo_factory_test.cpp
@@ -0,0 +1,52 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/repo/configbuilder.h>
+#include <vespa/document/repo/documenttyperepo.h>
+#include <vespa/document/repo/document_type_repo_factory.h>
+#include <vespa/vespalib/stllike/string.h>
+#include <vespa/vespalib/testkit/testapp.h>
+
+using vespalib::string;
+using namespace document::config_builder;
+using namespace document;
+
+namespace {
+
+const string type_name = "test";
+const int32_t doc_type_id = 787121340;
+const string header_name = type_name + ".header";
+const string body_name = type_name + ".body";
+
+std::shared_ptr<const DocumenttypesConfig>
+makeDocumentTypesConfig(const string &field_name)
+{
+ document::config_builder::DocumenttypesConfigBuilderHelper builder;
+ builder.document(doc_type_id, type_name,
+ Struct(header_name),
+ Struct(body_name).addField(field_name,
+ DataType::T_STRING));
+ return std::make_shared<const DocumenttypesConfig>(builder.config());
+}
+
+TEST("require that equal configs gives same repo")
+{
+ auto config1 = makeDocumentTypesConfig("a");
+ auto config2 = makeDocumentTypesConfig("b");
+ auto config3 = std::make_shared<const DocumenttypesConfig>(*config1);
+ auto config4 = std::make_shared<const DocumenttypesConfig>(*config2);
+ auto repo1 = DocumentTypeRepoFactory::make(*config1);
+ auto repo2 = DocumentTypeRepoFactory::make(*config2);
+ auto repo3 = DocumentTypeRepoFactory::make(*config3);
+ auto repo4 = DocumentTypeRepoFactory::make(*config4);
+ EXPECT_NOT_EQUAL(repo1, repo2);
+ EXPECT_EQUAL(repo1, repo3);
+ EXPECT_NOT_EQUAL(repo1, repo4);
+ EXPECT_NOT_EQUAL(repo2, repo3);
+ EXPECT_EQUAL(repo2, repo4);
+ EXPECT_NOT_EQUAL(repo3, repo4);
+}
+
+}
+
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index 410ac539ff4..05ec2ce99d0 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -118,7 +118,7 @@ public:
CPPUNIT_TEST_SUITE_REGISTRATION(DocumentSelectParserTest);
namespace {
- DocumentTypeRepo::SP _repo;
+ std::shared_ptr<const DocumentTypeRepo> _repo;
}
void DocumentSelectParserTest::setUp()
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp
index 70f16eccfe1..cade696e06c 100644
--- a/document/src/tests/fieldpathupdatetestcase.cpp
+++ b/document/src/tests/fieldpathupdatetestcase.cpp
@@ -23,7 +23,7 @@ namespace document {
using namespace fieldvalue;
struct FieldPathUpdateTestCase : public CppUnit::TestFixture {
- DocumentTypeRepo::SP _repo;
+ std::shared_ptr<const DocumentTypeRepo> _repo;
DocumentType _foobar_type;
void setUp() override;