summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p2pvr/daemon/unittests/testMaint.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp
index b399951..75f3a76 100644
--- a/p2pvr/daemon/unittests/testMaint.cpp
+++ b/p2pvr/daemon/unittests/testMaint.cpp
@@ -14,8 +14,11 @@
#include <linux/dvb/frontend.h>
#include <definedDirs.h>
#include "mockDefs.h"
+#include "sqlSelectDeserializer.h"
+#include "commonHelpers.h"
+#include <slicer/slicer.h>
-class Core {
+class Core : public CommonObjects {
public:
Core()
{
@@ -206,17 +209,49 @@ BOOST_AUTO_TEST_CASE( GetService )
BOOST_AUTO_TEST_CASE( update_events )
{
+ BOOST_CHECKPOINT("Get a DB connection for faking stuff");
+ auto db = this->dataSource<RdbmsDataSource>("postgres")->getReadonly(); // Naughty, but don't want txs
+
BOOST_CHECKPOINT("Write first events");
MockTuner::SetEventsSet(0);
m->UpdateEvents(FE_OFDM);
+ auto dayOneEvents = s->EventSearch(IceUtil::Optional<std::string>(), IceUtil::Optional<int>(),
+ Common::DateTime {2014, 12, 18, 3, 0}, Common::DateTime {2014, 12, 19, 3, 0});
+ BOOST_REQUIRE_EQUAL(dayOneEvents.size(), 3345);
BOOST_REQUIRE(s->GetEvent(14448, 27052));
BOOST_REQUIRE_THROW(s->GetEvent(15856, 3591), P2PVR::NotFound);
+ BOOST_CHECKPOINT("Fake some recorded stuff");
+ db->execute("INSERT INTO schedules(repeats) VALUES(false)");
+ db->execute("INSERT INTO recorded(scheduleId, eventUid) VALUES(1, 3)");
+ db->execute("INSERT INTO recordings(storageAddress, guid, scheduleId, eventUid) VALUES('', '', 1, 8)");
+ auto keyEvents = s->GetEvents({3, 8});
+ BOOST_REQUIRE_EQUAL(keyEvents.size(), 2);
+ BOOST_REQUIRE(keyEvents[0]->Current);
+ BOOST_REQUIRE_EQUAL(keyEvents[0]->StartTime, Common::DateTime({2014, 12, 18, 21, 0}));
+ BOOST_REQUIRE(keyEvents[1]->Current);
+ BOOST_REQUIRE_EQUAL(keyEvents[1]->StartTime, Common::DateTime({2014, 12, 17, 5, 30}));
+
BOOST_CHECKPOINT("Write second events");
MockTuner::SetEventsSet(1);
m->UpdateEvents(FE_OFDM);
BOOST_REQUIRE_THROW(s->GetEvent(14448, 27052), P2PVR::NotFound);
BOOST_REQUIRE(s->GetEvent(15856, 3591));
+
+ BOOST_CHECKPOINT("Check our faked stuff is still there and right");
+ auto dayOneEventsOnDayTwo = s->EventSearch(IceUtil::Optional<std::string>(), IceUtil::Optional<int>(),
+ Common::DateTime {2014, 12, 18, 3, 0}, Common::DateTime {2014, 12, 19, 3, 0});
+ // Some datetime range overlap, but most are gone
+ BOOST_REQUIRE_EQUAL(dayOneEventsOnDayTwo.size(), 373);
+ BOOST_REQUIRE_EQUAL(std::count_if(dayOneEventsOnDayTwo.begin(), dayOneEventsOnDayTwo.end(),
+ [](const P2PVR::EventPtr & e) { return e->EventUid == 3 || e->EventUid == 8; }), 0);
+ auto keyEventsOnDayTwo = s->GetEvents({3, 8});
+ BOOST_REQUIRE_EQUAL(keyEventsOnDayTwo.size(), 2);
+ BOOST_REQUIRE(!keyEventsOnDayTwo[0]->Current);
+ BOOST_REQUIRE(!keyEventsOnDayTwo[1]->Current);
+
+ BOOST_REQUIRE_EQUAL(keyEvents[0]->Title, keyEventsOnDayTwo[0]->Title);
+ BOOST_REQUIRE_EQUAL(keyEvents[1]->Title, keyEventsOnDayTwo[1]->Title);
}
BOOST_AUTO_TEST_SUITE_END()