From be4196efbe16a9af330510a9709a7038e039a21e Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 26 Nov 2024 11:29:53 -0800 Subject: [PATCH] test: Make eg.user more realistic about email and delivery email This better reflects the fact that a User object will often have null `deliveryEmail`, and that when that's the case it will have a server-generated fake email address in `email`. --- test/example_data.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/example_data.dart b/test/example_data.dart index 1dde6340b6..d071307ec4 100644 --- a/test/example_data.dart +++ b/test/example_data.dart @@ -106,9 +106,8 @@ int _lastEmailSuffix = 1000; /// other data in the test, or if the IDs need to increase in a different order /// from the calls to [user]. /// -/// If `deliveryEmail` is not given, it will be generated from a -/// random sequence of distinct strings. -/// If `email` is not given, it will be set to `deliveryEmail`. +/// If `email` is not given, it defaults to `deliveryEmail` if given, +/// or else to a value resembling the Zulip server's generated fake emails. User user({ int? userId, String? deliveryEmail, @@ -121,12 +120,12 @@ User user({ String? avatarUrl, Map? profileData, }) { - var effectiveDeliveryEmail = deliveryEmail ?? _nextEmail(); _checkPositive(userId, 'user ID'); + final effectiveUserId = userId ?? _nextUserId(); return User( - userId: userId ?? _nextUserId(), - deliveryEmail: effectiveDeliveryEmail, - email: email ?? effectiveDeliveryEmail, + userId: effectiveUserId, + deliveryEmail: deliveryEmail, + email: email ?? deliveryEmail ?? 'user$effectiveUserId@${realmUrl.host}', fullName: fullName ?? 'A user', // TODO generate example names dateJoined: dateJoined ?? '2024-02-24T11:18+00:00', isActive: isActive ?? true,