summaryrefslogtreecommitdiff
path: root/server/src/session.cc
diff options
context:
space:
mode:
authordeva <deva>2011-02-17 11:00:14 +0000
committerdeva <deva>2011-02-17 11:00:14 +0000
commitdb144840aba95affb3a6b5b2536059f49f0677ff (patch)
tree1c397a20aa5745c6bbb5dee6a4409f58c4542e87 /server/src/session.cc
parentc8651b8c89673300477ab86962640c93216ea306 (diff)
Rewrite of all old tests to new unittest framework. Also some work on testdb; more to come...
Diffstat (limited to 'server/src/session.cc')
-rw-r--r--server/src/session.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/server/src/session.cc b/server/src/session.cc
index fe05ee5..6880e73 100644
--- a/server/src/session.cc
+++ b/server/src/session.cc
@@ -298,14 +298,19 @@ SessionAutolock::~SessionAutolock()
#ifdef TEST_SESSION
//deps: configuration.cc journal.cc journal_uploadserver.cc journal_commit.cc mutex.cc debug.cc sessionserialiser.cc sessionparser.cc saxparser.cc environment.cc semaphore.cc artefact.cc xml_encode_decode.cc database.cc pracrodaopgsql.cc pracrodaotest.cc pracrodao.cc entitylist.cc macrolist.cc templatelist.cc macroheaderparser.cc templateheaderparser.cc versionstr.cc exception.cc log.cc inotify.cc
-//cflags: -I.. $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) $(ATF_CFLAGS) $(PQXX_CXXFLAGS)
-//libs: $(PTHREAD_LIBS) $(EXPAT_LIBS) $(ATF_LIBS) $(PQXX_LIBS)
+//cflags: -I.. $(PTHREAD_CFLAGS) $(EXPAT_CFLAGS) -DWITHOUT_ARTEFACT -DWITHOUT_DB
+//libs: $(PTHREAD_LIBS) $(EXPAT_LIBS)
#include <test.h>
#define PID "1505050505"
#define TMPL "test"
TEST_BEGIN;
+
+Conf::database_backend = "testdb";
+Conf::database_poolsize = 1;
+Conf::xml_basedir = "/tmp";
+
Environment env;
Conf::session_path = "/tmp";
@@ -325,6 +330,30 @@ TEST_NOTEQUAL_STR(s1->id(), s3->id(), "Testing if IDs are unique.");
TEST_EQUAL_INT(env.sessions.size(), 1, "Testing if size is 1.");
+std::string id = s3->id();
+env.sessions.deleteSession(id);
+Session *s4 = env.sessions.session(id);
+TEST_EQUAL(s4, NULL, "No session should be returned.");
+
+TEST_EQUAL_INT(env.sessions.size(), 0, "Testing if size is 0.");
+
+Session *s5 = env.sessions.newSession(PID, TMPL);
+TEST_NOTEQUAL(s5, NULL, "A new session was created.");
+
+s5->isreadonly = false;
+
+env.sessions.store();
+
+Session *s6 = env.sessions.session(id);
+TEST_EQUAL_STR(s6->id(), s5->id(), "Did we get the stored session?");
+
+s6->isreadonly = false;
+
+env.sessions.store();
+
+Session *s7 = env.sessions.newSession(PID, TMPL);
+TEST_EQUAL_STR(s7->id(), s5->id(), "Did we get the stored session?");
+
/*
std::string sessionid = s1->id();
SessionSerialiser ser(&env, Conf::session_path);