Skip to content

test: Use random topic in eg.streamMessage #932

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 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion test/example_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ int _lastMessageId = 1000;

const defaultStreamMessageStreamId = 123;

/// The default topic used by [streamMessage].
///
/// Tests generally shouldn't need this information directly.
/// Instead, either
/// * use [StreamMessage.topic] to read off an example message's topic;
/// * or pick an example topic, and pass it both to [streamMessage]
/// and wherever else the same topic is needed.
final _defaultTopic = 'example topic ${Random().nextInt(1000)}';

/// Construct an example stream message.
///
/// If the message ID `id` is not given, it will be generated from a random
Expand All @@ -331,6 +340,10 @@ const defaultStreamMessageStreamId = 123;
/// The message will be in `stream` if given. Otherwise,
/// an example stream with ID `defaultStreamMessageStreamId` will be used.
///
/// If `topic` is not given, a default topic name is used.
/// The default is randomly chosen, but remains the same
/// for subsequent calls to this function.
///
/// See also:
/// * [dmMessage], to construct an example direct message.
StreamMessage streamMessage({
Expand Down Expand Up @@ -363,7 +376,7 @@ StreamMessage streamMessage({
'flags': flags ?? [],
'id': id ?? _nextMessageId(),
'last_edit_timestamp': lastEditTimestamp,
'subject': topic ?? 'example topic',
'subject': topic ?? _defaultTopic,
'submessages': submessages ?? [],
'timestamp': timestamp ?? 1678139636,
'type': 'stream',
Expand Down