Mercurial > hg > orthanc-databases
changeset 301:2447c290fc73
added unit test
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 08 Jul 2021 18:28:47 +0200 |
parents | a116dbdf9118 |
children | 3a52e27a2d80 |
files | Framework/Plugins/IndexBackend.cpp Framework/Plugins/IndexUnitTests.h MySQL/CMakeLists.txt |
diffstat | 3 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/IndexBackend.cpp Wed Jul 07 16:48:58 2021 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Thu Jul 08 18:28:47 2021 +0200 @@ -735,6 +735,7 @@ "SELECT CAST(COUNT(*) AS BIGINT) FROM Resources WHERE resourceType=${type}")); break; + case Dialect_MSSQL: case Dialect_SQLite: statement.reset(new DatabaseManager::CachedStatement( STATEMENT_FROM_HERE, manager, @@ -803,6 +804,7 @@ "SELECT CAST(COALESCE(SUM(compressedSize), 0) AS BIGINT) FROM AttachedFiles")); break; + case Dialect_MSSQL: case Dialect_SQLite: statement.reset(new DatabaseManager::CachedStatement( STATEMENT_FROM_HERE, manager, @@ -840,6 +842,7 @@ "SELECT CAST(COALESCE(SUM(uncompressedSize), 0) AS BIGINT) FROM AttachedFiles")); break; + case Dialect_MSSQL: case Dialect_SQLite: statement.reset(new DatabaseManager::CachedStatement( STATEMENT_FROM_HERE, manager, @@ -1799,6 +1802,7 @@ break; case Dialect_SQLite: + case Dialect_MSSQL: statement.reset(new DatabaseManager::CachedStatement( STATEMENT_FROM_HERE, manager, "SELECT COUNT(*) FROM Resources"));
--- a/Framework/Plugins/IndexUnitTests.h Wed Jul 07 16:48:58 2021 +0200 +++ b/Framework/Plugins/IndexUnitTests.h Thu Jul 08 18:28:47 2021 +0200 @@ -214,6 +214,11 @@ ASSERT_TRUE(db.LookupGlobalProperty(s, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal9)); ASSERT_EQ("HelloWorld", s); + ASSERT_EQ(0u, db.GetAllResourcesCount(*manager)); + ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Patient)); + ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Study)); + ASSERT_EQ(0u, db.GetResourcesCount(*manager, OrthancPluginResourceType_Series)); + int64_t a = db.CreateResource(*manager, "study", OrthancPluginResourceType_Study); ASSERT_TRUE(db.IsExistingResource(*manager, a)); ASSERT_FALSE(db.IsExistingResource(*manager, a + 1));
--- a/MySQL/CMakeLists.txt Wed Jul 07 16:48:58 2021 +0200 +++ b/MySQL/CMakeLists.txt Thu Jul 08 18:28:47 2021 +0200 @@ -140,5 +140,7 @@ # reasons. Without this option, many symbols are left undefined # while linking "UnitTests" in release mode. Similar to: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14001 + # + # NB: This will be automatically added in Orthanc Framework > 1.9.5 target_link_libraries(UnitTests stdc++ m) endif()