Page MenuHomePhabricator

[services] Tunnelbroker - Add test for `removeMessageItemsByIDsForDeviceID` database function
ClosedPublic

Authored by max on Jul 7 2022, 8:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jul 7, 9:47 AM
Unknown Object (File)
Sat, Jul 6, 3:35 PM
Unknown Object (File)
Mon, Jun 24, 8:07 AM
Unknown Object (File)
Sun, Jun 23, 4:05 PM
Unknown Object (File)
Sat, Jun 22, 3:21 PM
Unknown Object (File)
Fri, Jun 21, 11:17 PM
Unknown Object (File)
Thu, Jun 20, 10:39 AM
Unknown Object (File)
Sat, Jun 15, 1:48 AM

Details

Summary

This diff introduces a test for removeMessageItemsByIDsForDeviceID database function which was introduced in D4476.
The function removes messages by the list of IDs and receiver deviceID in a batch.

Linear task: ENG-1361

Test Plan

Tests not fails when running yarn test-tunnelbroker-service

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max held this revision as a draft.
max published this revision for review.Jul 7 2022, 8:38 AM
max added reviewers: karol, tomek.
tomek added inline comments.
services/tunnelbroker/test/DatabaseManagerTest.cpp
318–339 ↗(On Diff #14285)

We should have a test that verifies that not all the messages are deleted - we should put a message with the same deviceID that isn't deleted and another message with a different deviceID

This revision is now accepted and ready to land.Jul 8 2022, 2:51 AM
karol added inline comments.
services/tunnelbroker/test/DatabaseManagerTest.cpp
305–321 ↗(On Diff #14285)

Wouldn't it be better to first check if the table is available and only then create the items?

309–316 ↗(On Diff #14285)

Shouldn't we add a constant with a value of 256?

320 ↗(On Diff #14285)

Does this compile? Am I missing something or item is not defined in the scope here?

This revision now requires changes to proceed.Jul 11 2022, 3:16 AM
max marked 4 inline comments as done.

Updates based on the comments.

services/tunnelbroker/test/DatabaseManagerTest.cpp
305–321 ↗(On Diff #14285)

Wouldn't it be better to first check if the table is available and only then create the items?

To invocate .getTableName() we need to create an database::MessageItem instance anyway. We can do this before but need to create an empty instance and we will have an additional instance of the database::MessageItem. So it doesn't worth it here.

309–316 ↗(On Diff #14285)

Shouldn't we add a constant with a value of 256?

Yes, sure! Done.

318–339 ↗(On Diff #14285)

We should have a test that verifies that not all the messages are deleted - we should put a message with the same deviceID that isn't deleted and another message with a different deviceID

Good catch. I've changed the test to insert three messages for the same deviceID, but to delete 2 of 3 messages. Then we check that the one message still persisted and was not deleted after calling the batch removing.

320 ↗(On Diff #14285)

Does this compile? Am I missing something or item is not defined in the scope here?

Fixed that nit. Re-checks it, now it compiles without errors. Thanks.

karol added inline comments.
services/tunnelbroker/test/DatabaseManagerTest.cpp
305–321 ↗(On Diff #14285)

right

This revision is now accepted and ready to land.Aug 1 2022, 2:28 AM