Mercurial > hg > orthanc
comparison UnitTestsSources/ServerIndexTests.cpp @ 1672:4c5a85c3ff43 db-changes
sample database plugin now working
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 12:20:49 +0200 |
parents | e5e975e9b738 |
children | 4db9200c7f46 |
comparison
equal
deleted
inserted
replaced
1671:2f2e2ec17bc4 | 1672:4c5a85c3ff43 |
---|---|
120 default: | 120 default: |
121 throw OrthancException(ErrorCode_InternalError); | 121 throw OrthancException(ErrorCode_InternalError); |
122 } | 122 } |
123 | 123 |
124 index_->SetListener(*listener_); | 124 index_->SetListener(*listener_); |
125 index_->Open(); | |
125 } | 126 } |
126 | 127 |
127 virtual void TearDown() | 128 virtual void TearDown() |
128 { | 129 { |
130 index_->Close(); | |
129 index_.reset(NULL); | 131 index_.reset(NULL); |
130 listener_.reset(NULL); | 132 listener_.reset(NULL); |
131 } | 133 } |
132 | 134 |
133 void CheckTableRecordCount(uint32_t expected, const char* table) | 135 void CheckTableRecordCount(uint32_t expected, const char* table) |
658 const std::string path = "UnitTestsStorage"; | 660 const std::string path = "UnitTestsStorage"; |
659 | 661 |
660 Toolbox::RemoveFile(path + "/index"); | 662 Toolbox::RemoveFile(path + "/index"); |
661 FilesystemStorage storage(path); | 663 FilesystemStorage storage(path); |
662 DatabaseWrapper db; // The SQLite DB is in memory | 664 DatabaseWrapper db; // The SQLite DB is in memory |
665 db.Open(); | |
663 ServerContext context(db, storage); | 666 ServerContext context(db, storage); |
664 ServerIndex& index = context.GetIndex(); | 667 ServerIndex& index = context.GetIndex(); |
665 | 668 |
666 ASSERT_EQ(1u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); | 669 ASSERT_EQ(1u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); |
667 ASSERT_EQ(2u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); | 670 ASSERT_EQ(2u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); |
668 ASSERT_EQ(3u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); | 671 ASSERT_EQ(3u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); |
669 ASSERT_EQ(4u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); | 672 ASSERT_EQ(4u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence)); |
670 | 673 |
671 context.Stop(); | 674 context.Stop(); |
675 db.Close(); | |
672 } | 676 } |
673 | 677 |
674 | 678 |
675 | 679 |
676 TEST_P(DatabaseWrapperTest, LookupIdentifier) | 680 TEST_P(DatabaseWrapperTest, LookupIdentifier) |
726 const std::string path = "UnitTestsStorage"; | 730 const std::string path = "UnitTestsStorage"; |
727 | 731 |
728 Toolbox::RemoveFile(path + "/index"); | 732 Toolbox::RemoveFile(path + "/index"); |
729 FilesystemStorage storage(path); | 733 FilesystemStorage storage(path); |
730 DatabaseWrapper db; // The SQLite DB is in memory | 734 DatabaseWrapper db; // The SQLite DB is in memory |
735 db.Open(); | |
731 ServerContext context(db, storage); | 736 ServerContext context(db, storage); |
732 ServerIndex& index = context.GetIndex(); | 737 ServerIndex& index = context.GetIndex(); |
733 | 738 |
734 index.SetMaximumStorageSize(10); | 739 index.SetMaximumStorageSize(10); |
735 | 740 |
779 | 784 |
780 // Because the DB is in memory, the SQLite index must not have been created | 785 // Because the DB is in memory, the SQLite index must not have been created |
781 ASSERT_THROW(Toolbox::GetFileSize(path + "/index"), OrthancException); | 786 ASSERT_THROW(Toolbox::GetFileSize(path + "/index"), OrthancException); |
782 | 787 |
783 context.Stop(); | 788 context.Stop(); |
789 db.Close(); | |
784 } | 790 } |