Skip to content

test: Use random email in eg.user #940

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 1 commit into from
Sep 16, 2024
Merged

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Sep 13, 2024

This specifically fixes a test data realism issue of the test "find account among several" in
test/notifications/display_test.dart due to duplicate email addresses within a realm. This also useful in general in cases when the email addresses do not matter and should be kept boring.

The generation uses an increasing sequence to make collision unlikely (still possible with caller specified values).

This is taken from #934 and similar to #932.

@PIG208 PIG208 requested a review from chrisbobbe September 13, 2024 03:03
@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Sep 13, 2024
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM with one suggestion below; marking for Greg's review.

@@ -70,13 +70,21 @@ GetServerSettingsResult serverSettings({
int _nextUserId() => (_lastUserId += 1 + Random().nextInt(100));
int _lastUserId = 1000;

/// A random email address, unique from previously generated ones.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// A random email address, unique from previously generated ones.
/// A random email address, different from previously generated ones.

@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Sep 13, 2024
@chrisbobbe chrisbobbe requested a review from gnprice September 13, 2024 23:25
This specifically fixes a test data realism issue of the test
"find account among several" in
`test/notifications/display_test.dart` due to duplicate email
addresses within a realm.  This also useful in general in cases
when the email addresses do not matter and should be kept boring.

The generation uses an increasing sequence to make collision unlikely
(still possible with caller specified values).

Signed-off-by: Zixuan James Li <zixuan@zulip.com>
@gnprice
Copy link
Member

gnprice commented Sep 16, 2024

Thanks @PIG208 for the fix, and @chrisbobbe for the previous review!

Looks good; merging, with one docs tweak:

-/// If `deliveryEmail` is not given, it will be generated from a random
-/// but unique sequence of strings.
+/// If `deliveryEmail` is not given, it will be generated from a
+/// random sequence of distinct strings.

For me saying the sequence is unique would mean that it's distinct from other sequences; instead we mean that all its elements are unique, i.e. distinct from each other.

@gnprice gnprice merged commit d1a2538 into zulip:main Sep 16, 2024
1 check passed
@PIG208 PIG208 deleted the pr-random-email branch September 17, 2024 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants