Skip to content

test [nfc]: Ensure user IDs, message IDs, etc. are positive #877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Aug 10, 2024

Zulip user IDs, message IDs, and stream/channel IDs (and anything else that's an ID of a row in the server database) are positive integers. So are our account IDs. To help keep test data realistic, enforce those in the example-data functions.

This follows up on 739fa84 (in #828; /cc @sm-sayedi), which made a similar fix for one test case.

gnprice added 4 commits August 9, 2024 21:18
Zulip user IDs are positive integers.  So avoiding zero here
helps keep the test data realistic.

This follows up on 739fa84 (in zulip#828), which made a similar fix
for one test case.
Zulip message IDs and stream/channel IDs, like user IDs, are positive
integers.  So avoiding zero for them helps keep the test data realistic.
Our account IDs are always positive integers, because they're generated
by inserting into an AUTOINCREMENT column in our SQLite database:
  https://www.sqlite.org/autoinc.html

So avoiding zero here helps keep the data realistic.
Unlike the various IDs for things in the database (users, messages,
etc.), which are always positive, Zulip event IDs start at zero.

Correspondingly, InitialSnapshot.lastEventId is -1 if there were no
events queued up concurrently with the initial snapshot getting
generated.

So in the spirit of maximum boringness for test data, use those
values by default.
@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Aug 10, 2024
@gnprice gnprice requested a review from PIG208 August 10, 2024 04:23
@chrisbobbe
Copy link
Collaborator

LGTM, thank you!

@chrisbobbe chrisbobbe merged commit aadec27 into zulip:main Aug 12, 2024
1 check passed
Copy link
Member

@PIG208 PIG208 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, looks like I have a comment that didn't get posted.

apiKey: 'user${i}apikey',
));
return List.generate(count, (i) {
final id = i+1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
final id = i+1;
final id = i + 1;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, thanks.

An expression like "x+1" is something I'm pretty happy with being formatted either way — that or x + 1. So we can just leave it be.

If at some point in the future dartfmt gains the needed flexibility for Flutter upstream to adopt it and we follow, then it'll presumably turn this to i + 1 and that'll be fine too.

@gnprice gnprice deleted the pr-test-validate-data branch August 13, 2024 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer review PR ready for review by Zulip maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants