diff options
author | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2015-11-06 15:40:06 +0000 |
---|---|---|
committer | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2015-11-06 15:40:06 +0000 |
commit | 84f5cd58857a6f8170d9531ac7cd75407bf6f83d (patch) | |
tree | 59e3e96e24866c0b092315a60a1a5e23ff43f52e | |
parent | Strip 'New:' from event titles (diff) | |
download | p2pvr-84f5cd58857a6f8170d9531ac7cd75407bf6f83d.tar.bz2 p2pvr-84f5cd58857a6f8170d9531ac7cd75407bf6f83d.tar.xz p2pvr-84f5cd58857a6f8170d9531ac7cd75407bf6f83d.zip |
Don't rely on sequence values as insert order isn't predictable
-rw-r--r-- | p2pvr/daemon/unittests/testMaint.cpp | 36 |
1 files 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::ModifyCommand>( + 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::ModifyCommand>( + 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 ) |