From 84f5cd58857a6f8170d9531ac7cd75407bf6f83d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 6 Nov 2015 15:40:06 +0000 Subject: Don't rely on sequence values as insert order isn't predictable --- p2pvr/daemon/unittests/testMaint.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp index a794e5e..ec04649 100644 --- a/p2pvr/daemon/unittests/testMaint.cpp +++ b/p2pvr/daemon/unittests/testMaint.cpp @@ -223,15 +223,25 @@ BOOST_AUTO_TEST_CASE( update_events ) BOOST_REQUIRE_THROW(s->GetEvent(15856, 3591), P2PVR::NotFound); BOOST_CHECKPOINT("Fake some recorded stuff"); + auto keyEvent1 = s->GetEvent(25664, 55689); + auto keyEvent2 = s->GetEvent(24256, 1014); 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})); + auto irecorded = boost::shared_ptr( + db->newModifyCommand("INSERT INTO recorded(scheduleId, eventUid) VALUES(?, ?)")); + irecorded->bindParamI(0, 1); + irecorded->bindParamI(1, keyEvent1->EventUid); + irecorded->execute(); + auto irecordings = boost::shared_ptr( + db->newModifyCommand("INSERT INTO recordings(storageAddress, guid, scheduleId, eventUid) VALUES('', '', ?, ?)")); + irecordings->bindParamI(0, 1); + irecordings->bindParamI(1, keyEvent2->EventUid); + irecordings->execute(); + BOOST_REQUIRE(keyEvent1); + BOOST_REQUIRE(keyEvent2); + BOOST_REQUIRE(keyEvent1->Current); + BOOST_REQUIRE_EQUAL(keyEvent1->StartTime, Common::DateTime({2014, 12, 18, 21, 0})); + BOOST_REQUIRE(keyEvent2->Current); + BOOST_REQUIRE_EQUAL(keyEvent2->StartTime, Common::DateTime({2014, 12, 17, 5, 30})); BOOST_CHECKPOINT("Write second events"); MockTuner::SetEventsSet(1); @@ -245,14 +255,16 @@ BOOST_AUTO_TEST_CASE( update_events ) // 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}); + [](const P2PVR::EventPtr & e) { + return (e->ServiceId == 25664 && e->EventId == 55689) + || (e->ServiceId == 24256 && e->EventId == 1014); }), 0); + auto keyEventsOnDayTwo = s->GetEvents({keyEvent1->EventUid, keyEvent2->EventUid}); 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_REQUIRE_EQUAL(keyEvent1->Title, keyEventsOnDayTwo[0]->Title); + BOOST_REQUIRE_EQUAL(keyEvent2->Title, keyEventsOnDayTwo[1]->Title); } BOOST_AUTO_TEST_CASE( test_titleFiltering ) -- cgit v1.2.3