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)
Sat, Nov 2, 2:37 PM
Unknown Object (File)
Sat, Nov 2, 2:37 PM
Unknown Object (File)
Sat, Nov 2, 2:36 PM
Unknown Object (File)
Sat, Nov 2, 2:36 PM
Unknown Object (File)
Sat, Nov 2, 2:33 PM
Unknown Object (File)
Wed, Oct 16, 8:34 PM
Unknown Object (File)
Wed, Oct 16, 8:12 PM
Unknown Object (File)
Wed, Oct 16, 8:11 PM

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