Mercurial > hg > orthanc-databases
annotate PostgreSQL/UnitTests/PostgreSQLTests.cpp @ 122:eb379b32f7ca pg-tcp-nodelay
closing branch pg-tcp-nodelay
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Feb 2019 16:33:59 +0100 |
parents | aceb0174c4ed |
children | cc3dc759c989 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
67 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include <gtest/gtest.h> | |
23 | |
24 #if defined(_WIN32) | |
25 // Fix redefinition of symbols on MinGW (these symbols are manually | |
26 // defined both by PostgreSQL and Google Test) | |
27 # undef S_IRGRP | |
28 # undef S_IROTH | |
29 # undef S_IRWXG | |
30 # undef S_IRWXO | |
31 # undef S_IWGRP | |
32 # undef S_IWOTH | |
33 # undef S_IXGRP | |
34 # undef S_IXOTH | |
35 #endif | |
36 | |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
37 #include "../Plugins/PostgreSQLIndex.h" |
14
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
38 #include "../Plugins/PostgreSQLStorageArea.h" |
0 | 39 #include "../../Framework/PostgreSQL/PostgreSQLTransaction.h" |
40 #include "../../Framework/PostgreSQL/PostgreSQLResult.h" | |
41 #include "../../Framework/PostgreSQL/PostgreSQLLargeObject.h" | |
42 | |
43 #include <Core/OrthancException.h> | |
44 | |
45 #include <boost/lexical_cast.hpp> | |
46 | |
47 using namespace OrthancDatabases; | |
48 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
49 extern PostgreSQLParameters globalParameters_; |
0 | 50 |
51 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
52 static PostgreSQLDatabase* CreateTestDatabase() |
0 | 53 { |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
54 std::auto_ptr<PostgreSQLDatabase> pg |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
55 (new PostgreSQLDatabase(globalParameters_)); |
0 | 56 |
57 pg->Open(); | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
58 pg->ClearAll(); |
0 | 59 |
60 return pg.release(); | |
61 } | |
62 | |
63 | |
64 static int64_t CountLargeObjects(PostgreSQLDatabase& db) | |
65 { | |
66 // Count the number of large objects in the DB | |
67 PostgreSQLStatement s(db, "SELECT COUNT(*) FROM pg_catalog.pg_largeobject", true); | |
68 PostgreSQLResult r(s); | |
69 return r.GetInteger64(0); | |
70 } | |
71 | |
72 | |
73 TEST(PostgreSQL, Basic) | |
74 { | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
75 std::auto_ptr<PostgreSQLDatabase> pg(CreateTestDatabase()); |
0 | 76 |
77 ASSERT_FALSE(pg->DoesTableExist("Test")); | |
78 pg->Execute("CREATE TABLE Test(name INTEGER, value BIGINT)"); | |
79 ASSERT_TRUE(pg->DoesTableExist("Test")); | |
80 | |
81 PostgreSQLStatement s(*pg, "INSERT INTO Test VALUES ($1,$2)", false); | |
82 s.DeclareInputInteger(0); | |
83 s.DeclareInputInteger64(1); | |
84 | |
85 s.BindInteger(0, 43); | |
86 s.BindNull(0); | |
87 s.BindInteger(0, 42); | |
88 s.BindInteger64(1, -4242); | |
89 s.Run(); | |
90 | |
91 s.BindInteger(0, 43); | |
92 s.BindNull(1); | |
93 s.Run(); | |
94 | |
95 s.BindNull(0); | |
96 s.BindInteger64(1, 4444); | |
97 s.Run(); | |
98 | |
99 { | |
100 PostgreSQLStatement t(*pg, "SELECT name, value FROM Test ORDER BY name", true); | |
101 PostgreSQLResult r(t); | |
102 | |
103 ASSERT_FALSE(r.IsDone()); | |
104 ASSERT_FALSE(r.IsNull(0)); ASSERT_EQ(42, r.GetInteger(0)); | |
105 ASSERT_FALSE(r.IsNull(1)); ASSERT_EQ(-4242, r.GetInteger64(1)); | |
106 | |
107 r.Next(); | |
108 ASSERT_FALSE(r.IsDone()); | |
109 ASSERT_FALSE(r.IsNull(0)); ASSERT_EQ(43, r.GetInteger(0)); | |
110 ASSERT_TRUE(r.IsNull(1)); | |
111 | |
112 r.Next(); | |
113 ASSERT_FALSE(r.IsDone()); | |
114 ASSERT_TRUE(r.IsNull(0)); | |
115 ASSERT_FALSE(r.IsNull(1)); ASSERT_EQ(4444, r.GetInteger64(1)); | |
116 | |
117 r.Next(); | |
118 ASSERT_TRUE(r.IsDone()); | |
119 } | |
120 | |
121 { | |
122 PostgreSQLStatement t(*pg, "SELECT name, value FROM Test WHERE name=$1", true); | |
123 t.DeclareInputInteger(0); | |
124 | |
125 { | |
126 t.BindInteger(0, 42); | |
127 PostgreSQLResult r(t); | |
128 ASSERT_FALSE(r.IsDone()); | |
129 ASSERT_FALSE(r.IsNull(0)); ASSERT_EQ(42, r.GetInteger(0)); | |
130 ASSERT_FALSE(r.IsNull(1)); ASSERT_EQ(-4242, r.GetInteger64(1)); | |
131 | |
132 r.Next(); | |
133 ASSERT_TRUE(r.IsDone()); | |
134 } | |
135 | |
136 { | |
137 t.BindInteger(0, 40); | |
138 PostgreSQLResult r(t); | |
139 ASSERT_TRUE(r.IsDone()); | |
140 } | |
141 } | |
142 | |
143 } | |
144 | |
145 | |
146 TEST(PostgreSQL, String) | |
147 { | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
148 std::auto_ptr<PostgreSQLDatabase> pg(CreateTestDatabase()); |
0 | 149 |
150 pg->Execute("CREATE TABLE Test(name INTEGER, value VARCHAR(40))"); | |
151 | |
152 PostgreSQLStatement s(*pg, "INSERT INTO Test VALUES ($1,$2)", false); | |
153 s.DeclareInputInteger(0); | |
154 s.DeclareInputString(1); | |
155 | |
156 s.BindInteger(0, 42); | |
157 s.BindString(1, "Hello"); | |
158 s.Run(); | |
159 | |
160 s.BindInteger(0, 43); | |
161 s.BindNull(1); | |
162 s.Run(); | |
163 | |
164 s.BindNull(0); | |
165 s.BindString(1, ""); | |
166 s.Run(); | |
167 | |
168 { | |
169 PostgreSQLStatement t(*pg, "SELECT name, value FROM Test ORDER BY name", true); | |
170 PostgreSQLResult r(t); | |
171 | |
172 ASSERT_FALSE(r.IsDone()); | |
173 ASSERT_FALSE(r.IsNull(0)); ASSERT_EQ(42, r.GetInteger(0)); | |
174 ASSERT_FALSE(r.IsNull(1)); ASSERT_EQ("Hello", r.GetString(1)); | |
175 | |
176 r.Next(); | |
177 ASSERT_FALSE(r.IsDone()); | |
178 ASSERT_FALSE(r.IsNull(0)); ASSERT_EQ(43, r.GetInteger(0)); | |
179 ASSERT_TRUE(r.IsNull(1)); | |
180 | |
181 r.Next(); | |
182 ASSERT_FALSE(r.IsDone()); | |
183 ASSERT_TRUE(r.IsNull(0)); | |
184 ASSERT_FALSE(r.IsNull(1)); ASSERT_EQ("", r.GetString(1)); | |
185 | |
186 r.Next(); | |
187 ASSERT_TRUE(r.IsDone()); | |
188 } | |
189 } | |
190 | |
191 | |
192 TEST(PostgreSQL, Transaction) | |
193 { | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
194 std::auto_ptr<PostgreSQLDatabase> pg(CreateTestDatabase()); |
0 | 195 |
196 pg->Execute("CREATE TABLE Test(name INTEGER, value INTEGER)"); | |
197 | |
198 { | |
199 PostgreSQLStatement s(*pg, "INSERT INTO Test VALUES ($1,$2)", false); | |
200 s.DeclareInputInteger(0); | |
201 s.DeclareInputInteger(1); | |
202 s.BindInteger(0, 42); | |
203 s.BindInteger(1, 4242); | |
204 s.Run(); | |
205 | |
206 { | |
207 PostgreSQLTransaction t(*pg); | |
208 s.BindInteger(0, 43); | |
209 s.BindInteger(1, 4343); | |
210 s.Run(); | |
211 s.BindInteger(0, 44); | |
212 s.BindInteger(1, 4444); | |
213 s.Run(); | |
214 | |
215 PostgreSQLStatement u(*pg, "SELECT COUNT(*) FROM Test", true); | |
216 PostgreSQLResult r(u); | |
217 ASSERT_EQ(3, r.GetInteger64(0)); | |
218 | |
219 // No commit | |
220 } | |
221 | |
222 { | |
223 PostgreSQLStatement u(*pg, "SELECT COUNT(*) FROM Test", true); | |
224 PostgreSQLResult r(u); | |
225 ASSERT_EQ(1, r.GetInteger64(0)); // Just "1" because of implicit rollback | |
226 } | |
227 | |
228 { | |
229 PostgreSQLTransaction t(*pg); | |
230 s.BindInteger(0, 43); | |
231 s.BindInteger(1, 4343); | |
232 s.Run(); | |
233 s.BindInteger(0, 44); | |
234 s.BindInteger(1, 4444); | |
235 s.Run(); | |
236 | |
237 { | |
238 PostgreSQLStatement u(*pg, "SELECT COUNT(*) FROM Test", true); | |
239 PostgreSQLResult r(u); | |
240 ASSERT_EQ(3, r.GetInteger64(0)); | |
241 | |
242 t.Commit(); | |
243 ASSERT_THROW(t.Rollback(), Orthanc::OrthancException); | |
244 ASSERT_THROW(t.Commit(), Orthanc::OrthancException); | |
245 } | |
246 } | |
247 | |
248 { | |
249 PostgreSQLStatement u(*pg, "SELECT COUNT(*) FROM Test", true); | |
250 PostgreSQLResult r(u); | |
251 ASSERT_EQ(3, r.GetInteger64(0)); | |
252 } | |
253 } | |
254 } | |
255 | |
256 | |
257 | |
258 | |
259 | |
260 TEST(PostgreSQL, LargeObject) | |
261 { | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
262 std::auto_ptr<PostgreSQLDatabase> pg(CreateTestDatabase()); |
0 | 263 ASSERT_EQ(0, CountLargeObjects(*pg)); |
264 | |
265 pg->Execute("CREATE TABLE Test(name VARCHAR, value OID)"); | |
266 | |
267 // Automatically remove the large objects associated with the table | |
268 pg->Execute("CREATE RULE TestDelete AS ON DELETE TO Test DO SELECT lo_unlink(old.value);"); | |
269 | |
270 { | |
271 PostgreSQLStatement s(*pg, "INSERT INTO Test VALUES ($1,$2)", false); | |
272 s.DeclareInputString(0); | |
273 s.DeclareInputLargeObject(1); | |
274 | |
275 for (int i = 0; i < 10; i++) | |
276 { | |
277 PostgreSQLTransaction t(*pg); | |
278 | |
279 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); | |
280 PostgreSQLLargeObject obj(*pg, value); | |
281 | |
282 s.BindString(0, "Index " + boost::lexical_cast<std::string>(i)); | |
283 s.BindLargeObject(1, obj); | |
284 s.Run(); | |
285 | |
286 std::string tmp; | |
287 PostgreSQLLargeObject::Read(tmp, *pg, obj.GetOid()); | |
288 ASSERT_EQ(value, tmp); | |
289 | |
290 t.Commit(); | |
291 } | |
292 } | |
293 | |
294 | |
295 ASSERT_EQ(10, CountLargeObjects(*pg)); | |
296 | |
297 { | |
298 PostgreSQLTransaction t(*pg); | |
299 PostgreSQLStatement s(*pg, "SELECT * FROM Test ORDER BY name DESC", true); | |
300 PostgreSQLResult r(s); | |
301 | |
302 ASSERT_FALSE(r.IsDone()); | |
303 | |
304 ASSERT_FALSE(r.IsNull(0)); | |
305 ASSERT_EQ("Index 9", r.GetString(0)); | |
306 | |
307 std::string data; | |
308 r.GetLargeObject(data, 1); | |
309 ASSERT_EQ("Value 18", data); | |
310 | |
311 r.Next(); | |
312 ASSERT_FALSE(r.IsDone()); | |
313 | |
314 //ASSERT_TRUE(r.IsString(0)); | |
315 } | |
316 | |
317 | |
318 { | |
319 PostgreSQLTransaction t(*pg); | |
320 PostgreSQLStatement s(*pg, "DELETE FROM Test WHERE name='Index 9'", false); | |
321 s.Run(); | |
322 t.Commit(); | |
323 } | |
324 | |
325 | |
326 { | |
327 // Count the number of items in the DB | |
328 PostgreSQLTransaction t(*pg); | |
329 PostgreSQLStatement s(*pg, "SELECT COUNT(*) FROM Test", true); | |
330 PostgreSQLResult r(s); | |
331 ASSERT_EQ(9, r.GetInteger64(0)); | |
332 } | |
333 | |
334 ASSERT_EQ(9, CountLargeObjects(*pg)); | |
335 } | |
336 | |
337 | |
14
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
338 TEST(PostgreSQL, StorageArea) |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
339 { |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
340 PostgreSQLStorageArea storageArea(globalParameters_); |
14
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
341 storageArea.SetClearAll(true); |
0 | 342 |
14
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
343 { |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
344 DatabaseManager::Transaction transaction(storageArea.GetManager()); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
345 PostgreSQLDatabase& db = |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
346 dynamic_cast<PostgreSQLDatabase&>(transaction.GetDatabase()); |
14
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
347 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
348 ASSERT_EQ(0, CountLargeObjects(db)); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
349 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
350 for (int i = 0; i < 10; i++) |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
351 { |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
352 std::string uuid = boost::lexical_cast<std::string>(i); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
353 std::string value = "Value " + boost::lexical_cast<std::string>(i * 2); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
354 storageArea.Create(transaction, uuid, value.c_str(), value.size(), OrthancPluginContentType_Unknown); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
355 } |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
356 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
357 std::string tmp; |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
358 ASSERT_THROW(storageArea.ReadToString(tmp, transaction, "nope", OrthancPluginContentType_Unknown), |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
359 Orthanc::OrthancException); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
360 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
361 ASSERT_EQ(10, CountLargeObjects(db)); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
362 storageArea.Remove(transaction, "5", OrthancPluginContentType_Unknown); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
363 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
364 ASSERT_EQ(9, CountLargeObjects(db)); |
0 | 365 |
14
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
366 for (int i = 0; i < 10; i++) |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
367 { |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
368 std::string uuid = boost::lexical_cast<std::string>(i); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
369 std::string expected = "Value " + boost::lexical_cast<std::string>(i * 2); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
370 std::string content; |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
371 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
372 if (i == 5) |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
373 { |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
374 ASSERT_THROW(storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown), |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
375 Orthanc::OrthancException); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
376 } |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
377 else |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
378 { |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
379 storageArea.ReadToString(content, transaction, uuid, OrthancPluginContentType_Unknown); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
380 ASSERT_EQ(expected, content); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
381 } |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
382 } |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
383 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
384 for (int i = 0; i < 10; i++) |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
385 { |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
386 storageArea.Remove(transaction, boost::lexical_cast<std::string>(i), |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
387 OrthancPluginContentType_Unknown); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
388 } |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
389 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
390 ASSERT_EQ(0, CountLargeObjects(db)); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
391 |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
392 transaction.Commit(); |
9774802fd05f
PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5
diff
changeset
|
393 } |
0 | 394 } |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
395 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
396 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
397 TEST(PostgreSQL, ImplicitTransaction) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
398 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
399 std::auto_ptr<PostgreSQLDatabase> db(CreateTestDatabase()); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
400 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
401 ASSERT_FALSE(db->DoesTableExist("test")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
402 ASSERT_FALSE(db->DoesTableExist("test2")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
403 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
404 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
405 std::auto_ptr<OrthancDatabases::ITransaction> t(db->CreateTransaction(false)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
406 ASSERT_FALSE(t->IsImplicit()); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
407 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
408 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
409 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
410 Query query("CREATE TABLE test(id INT)", false); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
411 std::auto_ptr<IPrecompiledStatement> s(db->Compile(query)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
412 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
413 std::auto_ptr<ITransaction> t(db->CreateTransaction(true)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
414 ASSERT_TRUE(t->IsImplicit()); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
415 ASSERT_THROW(t->Commit(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
416 ASSERT_THROW(t->Rollback(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
417 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
418 Dictionary args; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
419 t->ExecuteWithoutResult(*s, args); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
420 ASSERT_THROW(t->Rollback(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
421 t->Commit(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
422 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
423 ASSERT_THROW(t->Commit(), Orthanc::OrthancException); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
424 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
425 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
426 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
427 // An implicit transaction does not need to be explicitely committed |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
428 Query query("CREATE TABLE test2(id INT)", false); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
429 std::auto_ptr<IPrecompiledStatement> s(db->Compile(query)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
430 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
431 std::auto_ptr<ITransaction> t(db->CreateTransaction(true)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
432 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
433 Dictionary args; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
434 t->ExecuteWithoutResult(*s, args); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
435 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
436 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
437 ASSERT_TRUE(db->DoesTableExist("test")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
438 ASSERT_TRUE(db->DoesTableExist("test2")); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
439 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
14
diff
changeset
|
440 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
441 |
78 | 442 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
443 TEST(PostgreSQLIndex, CreateInstance) |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
444 { |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
445 OrthancDatabases::PostgreSQLIndex db(globalParameters_); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
446 db.SetClearAll(true); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
447 db.Open(); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
448 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
449 std::string s; |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
450 ASSERT_TRUE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_DatabaseInternal1)); |
95 | 451 ASSERT_EQ("2", s); |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
452 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
453 OrthancPluginCreateInstanceResult r1, r2; |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
454 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
455 memset(&r1, 0, sizeof(r1)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
456 db.CreateInstance(r1, "a", "b", "c", "d"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
457 ASSERT_TRUE(r1.isNewInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
458 ASSERT_TRUE(r1.isNewSeries); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
459 ASSERT_TRUE(r1.isNewStudy); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
460 ASSERT_TRUE(r1.isNewPatient); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
461 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
462 memset(&r2, 0, sizeof(r2)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
463 db.CreateInstance(r2, "a", "b", "c", "d"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
464 ASSERT_FALSE(r2.isNewInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
465 ASSERT_EQ(r1.instanceId, r2.instanceId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
466 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
467 // Breaking the hierarchy |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
468 memset(&r2, 0, sizeof(r2)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
469 ASSERT_THROW(db.CreateInstance(r2, "a", "e", "c", "f"), Orthanc::OrthancException); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
470 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
471 memset(&r2, 0, sizeof(r2)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
472 db.CreateInstance(r2, "a", "b", "c", "e"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
473 ASSERT_TRUE(r2.isNewInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
474 ASSERT_FALSE(r2.isNewSeries); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
475 ASSERT_FALSE(r2.isNewStudy); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
476 ASSERT_FALSE(r2.isNewPatient); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
477 ASSERT_EQ(r1.patientId, r2.patientId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
478 ASSERT_EQ(r1.studyId, r2.studyId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
479 ASSERT_EQ(r1.seriesId, r2.seriesId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
480 ASSERT_NE(r1.instanceId, r2.instanceId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
481 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
482 memset(&r2, 0, sizeof(r2)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
483 db.CreateInstance(r2, "a", "b", "f", "g"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
484 ASSERT_TRUE(r2.isNewInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
485 ASSERT_TRUE(r2.isNewSeries); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
486 ASSERT_FALSE(r2.isNewStudy); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
487 ASSERT_FALSE(r2.isNewPatient); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
488 ASSERT_EQ(r1.patientId, r2.patientId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
489 ASSERT_EQ(r1.studyId, r2.studyId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
490 ASSERT_NE(r1.seriesId, r2.seriesId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
491 ASSERT_NE(r1.instanceId, r2.instanceId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
492 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
493 memset(&r2, 0, sizeof(r2)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
494 db.CreateInstance(r2, "a", "h", "i", "j"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
495 ASSERT_TRUE(r2.isNewInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
496 ASSERT_TRUE(r2.isNewSeries); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
497 ASSERT_TRUE(r2.isNewStudy); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
498 ASSERT_FALSE(r2.isNewPatient); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
499 ASSERT_EQ(r1.patientId, r2.patientId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
500 ASSERT_NE(r1.studyId, r2.studyId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
501 ASSERT_NE(r1.seriesId, r2.seriesId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
502 ASSERT_NE(r1.instanceId, r2.instanceId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
503 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
504 memset(&r2, 0, sizeof(r2)); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
505 db.CreateInstance(r2, "k", "l", "m", "n"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
506 ASSERT_TRUE(r2.isNewInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
507 ASSERT_TRUE(r2.isNewSeries); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
508 ASSERT_TRUE(r2.isNewStudy); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
509 ASSERT_TRUE(r2.isNewPatient); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
510 ASSERT_NE(r1.patientId, r2.patientId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
511 ASSERT_NE(r1.studyId, r2.studyId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
512 ASSERT_NE(r1.seriesId, r2.seriesId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
513 ASSERT_NE(r1.instanceId, r2.instanceId); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
514 } |
73
aa81c1c80c75
fix compatibility with older sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
71
diff
changeset
|
515 #endif |