summaryrefslogtreecommitdiff
path: root/server/src/sessionserialiser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/sessionserialiser.cc')
-rw-r--r--server/src/sessionserialiser.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/server/src/sessionserialiser.cc b/server/src/sessionserialiser.cc
index 99f880b..b9e825a 100644
--- a/server/src/sessionserialiser.cc
+++ b/server/src/sessionserialiser.cc
@@ -252,10 +252,15 @@ Session *SessionSerialiser::findFromTupple(const std::string &patientid,
#define SID "42"
#define PID "1234567890"
#define TID "sometemplate"
-#define SPATH "/tmp"
TEST_BEGIN;
+// Make sure we start out on an empty session directory.
+std::string spath = "/tmp/test_sessionserialiser";
+while(mkdir(spath.c_str(), 0777) == -1 && errno == EEXIST) {
+ spath += "X";
+}
+
std::string xml;
debug_parse("+all");
@@ -283,7 +288,7 @@ Environment env;
j->addEntry("some text", "macro1", 0);
j->addEntry("some more text", "macro2", 2);
j->addEntry("yet some more text", "macro3", 1);
- SessionSerialiser s(&env, SPATH);
+ SessionSerialiser s(&env, spath);
xml = s.saveStr(&session);
s.loadStr(xml);
std::string xml2 = s.saveStr(&session);
@@ -296,13 +301,13 @@ Environment env;
j->addEntry("some text", "macro1", 0);
j->addEntry("some more text", "macro2", 2);
j->addEntry("yet some more text", "macro3", 1);
- SessionSerialiser s(&env, SPATH);
+ SessionSerialiser s(&env, spath);
xml = s.saveStr(&session);
}
/*
{
Session session(SID, PID, TID);
- SessionSerialiser s(SPATH);
+ SessionSerialiser s(spath);
s.loadStr(xml);
std::string xml2 = s.saveStr(&session);
TEST_EQUAL_STR(xml, xml2, "Compare");
@@ -314,13 +319,13 @@ Environment env;
j->addEntry("some text", "macro1", 0);
j->addEntry("some more text", "macro2", 2);
j->addEntry("yet some more text", "macro3", 1);
- SessionSerialiser s(&env, SPATH);
+ SessionSerialiser s(&env, spath);
s.save(&session);
}
/*
{
Session session(SID, PID, TID);
- SessionSerialiser s(SPATH);
+ SessionSerialiser s(spath);
s.load(SID);
std::string xml2 = s.saveStr(&session);
TEST_EQUAL_STR(xml, xml2, "Compare");
@@ -329,7 +334,7 @@ Environment env;
{
Session session(&env, SID, PID, TID);
- SessionSerialiser s(&env, SPATH);
+ SessionSerialiser s(&env, spath);
s.save(&session);
Session *s1 = s.findFromTupple(PID, TID);
TEST_NOTEQUAL(s1, NULL, "Found it?");