Skip to content

Commit 31e7a07

Browse files
committed
test: Use stream ID in default name and description in eg.stream
In particular this means that repeated calls `eg.stream()` with no arguments will get distinct names, as well as IDs, so that they can all be added to the same store without collision. Then also simplify away the various places where a test was passing a stream name when the only thing about the name that mattered to the test was being distinct from other names (or when nothing about the name mattered to the test at all).
1 parent d558988 commit 31e7a07

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

test/example_data.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,14 @@ ZulipStream stream({
175175
int? canRemoveSubscribersGroup,
176176
int? streamWeeklyTraffic,
177177
}) {
178+
var effectiveStreamId = streamId ?? _nextStreamId();
179+
var effectiveName = name ?? 'stream $effectiveStreamId';
180+
var effectiveDescription = description ?? 'Description of $effectiveName';
178181
return ZulipStream(
179-
streamId: streamId ?? _nextStreamId(),
180-
name: name ?? 'A stream', // TODO generate example names
181-
description: description ?? 'A description', // TODO generate example descriptions
182-
renderedDescription: renderedDescription ?? '<p>A description</p>', // TODO generate random
182+
streamId: effectiveStreamId,
183+
name: effectiveName,
184+
description: effectiveDescription,
185+
renderedDescription: renderedDescription ?? '<p>$effectiveDescription</p>',
183186
dateCreated: dateCreated ?? 1686774898,
184187
firstMessageId: firstMessageId,
185188
inviteOnly: inviteOnly ?? false,

test/model/channel_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ void main() {
3434
}
3535

3636
test('initial', () {
37-
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
38-
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
37+
final stream1 = eg.stream();
38+
final stream2 = eg.stream();
3939
checkUnified(eg.store(initialSnapshot: eg.initialSnapshot(
4040
streams: [stream1, stream2],
4141
subscriptions: [eg.subscription(stream1)],
4242
)));
4343
});
4444

4545
test('added by events', () async {
46-
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
47-
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
46+
final stream1 = eg.stream();
47+
final stream2 = eg.stream();
4848
final store = eg.store();
4949
checkUnified(store);
5050

@@ -106,8 +106,8 @@ void main() {
106106
});
107107

108108
group('topic visibility', () {
109-
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
110-
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
109+
final stream1 = eg.stream();
110+
final stream2 = eg.stream();
111111

112112
group('getter topicVisibilityPolicy', () {
113113
test('with nothing for stream', () {

test/model/message_list_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ void main() {
467467
});
468468

469469
group('messagesMoved', () {
470-
final stream = eg.stream(streamId: 1, name: 'test stream');
471-
final otherStream = eg.stream(streamId: 2, name: 'other stream');
470+
final stream = eg.stream();
471+
final otherStream = eg.stream();
472472

473473
void checkHasMessages(Iterable<Message> messages) {
474474
check(model.messages.map((e) => e.id)).deepEquals(messages.map((e) => e.id));
@@ -1094,8 +1094,8 @@ void main() {
10941094

10951095
group('stream/topic muting', () {
10961096
test('in CombinedFeedNarrow', () async {
1097-
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
1098-
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
1097+
final stream1 = eg.stream();
1098+
final stream2 = eg.stream();
10991099
await prepare(narrow: const CombinedFeedNarrow());
11001100
await store.addStreams([stream1, stream2]);
11011101
await store.addSubscription(eg.subscription(stream1));
@@ -1157,7 +1157,7 @@ void main() {
11571157
});
11581158

11591159
test('in ChannelNarrow', () async {
1160-
final stream = eg.stream(streamId: 1, name: 'stream 1');
1160+
final stream = eg.stream();
11611161
await prepare(narrow: ChannelNarrow(stream.streamId));
11621162
await store.addStream(stream);
11631163
await store.addSubscription(eg.subscription(stream, isMuted: true));
@@ -1204,7 +1204,7 @@ void main() {
12041204
});
12051205

12061206
test('in TopicNarrow', () async {
1207-
final stream = eg.stream(streamId: 1, name: 'stream 1');
1207+
final stream = eg.stream();
12081208
await prepare(narrow: TopicNarrow(stream.streamId, 'A'));
12091209
await store.addStream(stream);
12101210
await store.addSubscription(eg.subscription(stream, isMuted: true));
@@ -1236,7 +1236,7 @@ void main() {
12361236
});
12371237

12381238
test('in MentionsNarrow', () async {
1239-
final stream = eg.stream(streamId: 1, name: 'muted stream');
1239+
final stream = eg.stream();
12401240
const mutedTopic = 'muted';
12411241
await prepare(narrow: const MentionsNarrow());
12421242
await store.addStream(stream);

test/model/unreads_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ void main() {
153153

154154
group('count helpers', () {
155155
test('countInCombinedFeedNarrow', () async {
156-
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
157-
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
158-
final stream3 = eg.stream(streamId: 3, name: 'stream 3');
156+
final stream1 = eg.stream();
157+
final stream2 = eg.stream();
158+
final stream3 = eg.stream();
159159
prepare();
160160
await channelStore.addStreams([stream1, stream2, stream3]);
161161
await channelStore.addSubscription(eg.subscription(stream1));

test/widgets/message_list_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ void main() {
623623

624624
group('Update Narrow on message move', () {
625625
const topic = 'foo';
626-
final channel = eg.stream(name: 'move test stream');
627-
final otherChannel = eg.stream(name: 'other move test stream');
626+
final channel = eg.stream();
627+
final otherChannel = eg.stream();
628628
final narrow = TopicNarrow(channel.streamId, topic);
629629

630630
void prepareGetMessageResponse(List<Message> messages) {

test/widgets/subscription_list_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ void main() {
284284
check(wght).equals(expectedWght);
285285
}
286286

287-
final unmutedStreamWithUnmutedUnreads = eg.stream(name: 'Unmuted stream with unmuted unreads');
288-
final unmutedStreamWithNoUnmutedUnreads = eg.stream(name: 'Unmuted stream with no unmuted unreads');
289-
final mutedStreamWithUnmutedUnreads = eg.stream(name: 'Muted stream with unmuted unreads');
290-
final mutedStreamWithNoUnmutedUnreads = eg.stream(name: 'Muted stream with no unmuted unreads');
287+
final unmutedStreamWithUnmutedUnreads = eg.stream();
288+
final unmutedStreamWithNoUnmutedUnreads = eg.stream();
289+
final mutedStreamWithUnmutedUnreads = eg.stream();
290+
final mutedStreamWithNoUnmutedUnreads = eg.stream();
291291

292292
await setupStreamListPage(tester,
293293
subscriptions: [

0 commit comments

Comments
 (0)