Skip to content

Commit e34c06f

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 a8f6fa7 commit e34c06f

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
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/message_list_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ void main() {
426426
});
427427

428428
group('messagesMoved', () {
429-
final stream = eg.stream(streamId: 1, name: 'test stream');
430-
final otherStream = eg.stream(streamId: 2, name: 'other stream');
429+
final stream = eg.stream();
430+
final otherStream = eg.stream();
431431

432432
void checkHasMessages(Iterable<Message> messages) {
433433
check(model.messages.map((e) => e.id)).deepEquals(messages.map((e) => e.id));
@@ -904,8 +904,8 @@ void main() {
904904

905905
group('stream/topic muting', () {
906906
test('in CombinedFeedNarrow', () async {
907-
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
908-
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
907+
final stream1 = eg.stream();
908+
final stream2 = eg.stream();
909909
await prepare(narrow: const CombinedFeedNarrow());
910910
await store.addStreams([stream1, stream2]);
911911
await store.addSubscription(eg.subscription(stream1));
@@ -967,7 +967,7 @@ void main() {
967967
});
968968

969969
test('in StreamNarrow', () async {
970-
final stream = eg.stream(streamId: 1, name: 'stream 1');
970+
final stream = eg.stream();
971971
await prepare(narrow: StreamNarrow(stream.streamId));
972972
await store.addStream(stream);
973973
await store.addSubscription(eg.subscription(stream, isMuted: true));
@@ -1014,7 +1014,7 @@ void main() {
10141014
});
10151015

10161016
test('in TopicNarrow', () async {
1017-
final stream = eg.stream(streamId: 1, name: 'stream 1');
1017+
final stream = eg.stream();
10181018
await prepare(narrow: TopicNarrow(stream.streamId, 'A'));
10191019
await store.addStream(stream);
10201020
await store.addSubscription(eg.subscription(stream, isMuted: true));

test/model/stream_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/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 streamStore.addStreams([stream1, stream2, stream3]);
161161
await streamStore.addSubscription(eg.subscription(stream1));

0 commit comments

Comments
 (0)