comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 4589:bec74e29f86b db-changes

attaching the listener to transactions in IDatabaseWrapper
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Mar 2021 15:33:47 +0100
parents 9224e107d613
children ff8170d17d90
comparison
equal deleted inserted replaced
4588:94147ce2f097 4589:bec74e29f86b
81 deletedFiles_.push_back(fileUuid); 81 deletedFiles_.push_back(fileUuid);
82 LOG(INFO) << "A file must be removed: " << fileUuid; 82 LOG(INFO) << "A file must be removed: " << fileUuid;
83 } 83 }
84 84
85 virtual void SignalResourceDeleted(ResourceType type, 85 virtual void SignalResourceDeleted(ResourceType type,
86 const std::string& publicId) 86 const std::string& publicId) ORTHANC_OVERRIDE
87 { 87 {
88 LOG(INFO) << "Deleted resource " << publicId << " of type " << EnumerationToString(type); 88 LOG(INFO) << "Deleted resource " << publicId << " of type " << EnumerationToString(type);
89 deletedResources_.push_back(publicId); 89 deletedResources_.push_back(publicId);
90 } 90 }
91 }; 91 };
94 class DatabaseWrapperTest : public ::testing::Test 94 class DatabaseWrapperTest : public ::testing::Test
95 { 95 {
96 protected: 96 protected:
97 std::unique_ptr<TestDatabaseListener> listener_; 97 std::unique_ptr<TestDatabaseListener> listener_;
98 std::unique_ptr<SQLiteDatabaseWrapper> index_; 98 std::unique_ptr<SQLiteDatabaseWrapper> index_;
99 std::unique_ptr<IDatabaseWrapper::ITransaction> transaction_;
99 100
100 public: 101 public:
101 DatabaseWrapperTest() 102 DatabaseWrapperTest()
102 { 103 {
103 } 104 }
104 105
105 virtual void SetUp() ORTHANC_OVERRIDE 106 virtual void SetUp() ORTHANC_OVERRIDE
106 { 107 {
107 listener_.reset(new TestDatabaseListener); 108 listener_.reset(new TestDatabaseListener);
108 index_.reset(new SQLiteDatabaseWrapper); 109 index_.reset(new SQLiteDatabaseWrapper);
109 index_->SetListener(*listener_);
110 index_->Open(); 110 index_->Open();
111 transaction_.reset(index_->StartTransaction(TransactionType_ReadWrite, *listener_));
111 } 112 }
112 113
113 virtual void TearDown() ORTHANC_OVERRIDE 114 virtual void TearDown() ORTHANC_OVERRIDE
114 { 115 {
116 transaction_->Commit(0);
117 transaction_.reset();
118
115 index_->Close(); 119 index_->Close();
116 index_.reset(NULL); 120 index_.reset(NULL);
117 listener_.reset(NULL); 121 listener_.reset(NULL);
118 } 122 }
119 123