From 8ffb89d2d74b88d43dadbb5006d3c23592b088ed Mon Sep 17 00:00:00 2001 From: starlord Date: Sun, 30 Jun 2019 15:20:36 +0800 Subject: [PATCH] add more unittest Former-commit-id: 853d82c0f7b81579d1332c5f1eb08234bc49a065 --- cpp/unittest/db/meta_tests.cpp | 5 ++++- cpp/unittest/db/misc_test.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/cpp/unittest/db/meta_tests.cpp b/cpp/unittest/db/meta_tests.cpp index f6c9551a..0f3a92af 100644 --- a/cpp/unittest/db/meta_tests.cpp +++ b/cpp/unittest/db/meta_tests.cpp @@ -265,5 +265,8 @@ TEST_F(MetaTest, TABLE_FILES_TEST) { ASSERT_EQ(dated_files[table_file.date_].size(), to_index_files_cnt+raw_files_cnt+index_files_cnt); - + status = impl_->FilesToSearch(table_id, meta::DatesT(), dated_files); + ASSERT_TRUE(status.ok()); + ASSERT_EQ(dated_files[table_file.date_].size(), + to_index_files_cnt+raw_files_cnt+index_files_cnt); } diff --git a/cpp/unittest/db/misc_test.cpp b/cpp/unittest/db/misc_test.cpp index 6f1f87c8..4356746f 100644 --- a/cpp/unittest/db/misc_test.cpp +++ b/cpp/unittest/db/misc_test.cpp @@ -13,11 +13,19 @@ #include "db/Status.h" #include "db/Options.h" #include "db/DBMetaImpl.h" +#include "db/EngineFactory.h" #include using namespace zilliz::milvus; +namespace { + void CopyStatus(engine::Status& st1, engine::Status& st2) { + st1 = st2; + } + +} + TEST(DBMiscTest, ENGINE_API_TEST) { //engine api AddWithIdArray const uint16_t dim = 512; @@ -34,6 +42,15 @@ TEST(DBMiscTest, ENGINE_API_TEST) { auto status = engine.AddWithIdArray(vectors, ids); ASSERT_TRUE(status.ok()); + + auto engine_ptr = engine::EngineFactory::Build(128, "/tmp", engine::EngineType::INVALID); + ASSERT_EQ(engine_ptr, nullptr); + + engine_ptr = engine::EngineFactory::Build(128, "/tmp", engine::EngineType::FAISS_IVFFLAT); + ASSERT_NE(engine_ptr, nullptr); + + engine_ptr = engine::EngineFactory::Build(128, "/tmp", engine::EngineType::FAISS_IDMAP); + ASSERT_NE(engine_ptr, nullptr); } TEST(DBMiscTest, EXCEPTION_TEST) { @@ -65,6 +82,10 @@ TEST(DBMiscTest, STATUS_TEST) { ASSERT_TRUE(status.IsDBTransactionError()); str = status.ToString(); ASSERT_FALSE(str.empty()); + + engine::Status status_copy = engine::Status::OK(); + CopyStatus(status_copy, status); + ASSERT_TRUE(status.IsDBTransactionError()); } TEST(DBMiscTest, OPTIONS_TEST) { @@ -88,6 +109,19 @@ TEST(DBMiscTest, OPTIONS_TEST) { engine::ArchiveConf archive("delete", "1:2:3"); ASSERT_TRUE(archive.GetCriterias().empty()); } + + { + engine::ArchiveConf archive("delete"); + engine::ArchiveConf::CriteriaT criterial = { + {"disk", 1024}, + {"days", 100} + }; + archive.SetCriterias(criterial); + + auto crit = archive.GetCriterias(); + ASSERT_EQ(criterial["disk"], 1024); + ASSERT_EQ(criterial["days"], 100); + } } TEST(DBMiscTest, META_TEST) { -- GitLab