Changeset View
Changeset View
Standalone View
Standalone View
src/tests/client/room/purge-test.cpp
| Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | TEST_CASE("PurgeRoomTimelineAction", "[client][room][purge]") | ||||
| auto r1 = makeRoom(withRoomTimeline(events)); | auto r1 = makeRoom(withRoomTimeline(events)); | ||||
| auto r2 = makeRoom(withRoomTimeline(events)); | auto r2 = makeRoom(withRoomTimeline(events)); | ||||
| auto r3 = makeRoom(withRoomTimeline(events)); | auto r3 = makeRoom(withRoomTimeline(events)); | ||||
| auto m = makeClient(withRoom(r1) | withRoom(r2) | withRoom(r3)); | auto m = makeClient(withRoom(r1) | withRoom(r2) | withRoom(r3)); | ||||
| auto u = makeMockSdkUtil(m); | auto u = makeMockSdkUtil(m); | ||||
| auto d = u.getMockDispatcher(passDown<PurgeRoomTimelineAction>()); | auto d = u.getMockDispatcher(passDown<PurgeRoomTimelineAction>()); | ||||
| auto c = u.getClient(d); | auto c = u.getClient(d); | ||||
| bool saveEventsRequested = false; | |||||
| auto watchable = u.ee.watchable(); | |||||
| watchable.after<SaveEventsRequested>([&saveEventsRequested](auto &&) { | |||||
| saveEventsRequested = true; | |||||
| }); | |||||
| c.purgeRoomEvents({ | c.purgeRoomEvents({ | ||||
| {r1.roomId, 80}, | {r1.roomId, 80}, | ||||
| {r2.roomId, 50}, | {r2.roomId, 50}, | ||||
| }).then([&u](const auto &stat) { | }).then([&u](const auto &stat) { | ||||
| REQUIRE(stat); | REQUIRE(stat); | ||||
| u.io.stop(); | u.io.stop(); | ||||
| }); | }); | ||||
| u.io.run(); | u.io.run(); | ||||
| REQUIRE(c.room(r1.roomId).timelineEventIds().get().size() == 80); | REQUIRE(c.room(r1.roomId).timelineEventIds().get().size() == 80); | ||||
| REQUIRE(c.room(r2.roomId).timelineEventIds().get().size() == 50); | REQUIRE(c.room(r2.roomId).timelineEventIds().get().size() == 50); | ||||
| REQUIRE(c.room(r3.roomId).timelineEventIds().get().size() == 100); | REQUIRE(c.room(r3.roomId).timelineEventIds().get().size() == 100); | ||||
| REQUIRE(!saveEventsRequested); | |||||
| } | } | ||||