Skip to content

Commit

Permalink
Regression test for error rejecting transaction (#230)
Browse files Browse the repository at this point in the history
Towards #229

Add a skipped test demonstrating the sequence of interaction with a
StreamQueueTransaction that leads to a `StateError` during the call to
`transaction.reject()`.
  • Loading branch information
natebosch committed Apr 19, 2023
1 parent 0127813 commit ce650b0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/stream_queue_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,25 @@ void main() {
await flushMicrotasks();
controller.close();
});

test(
'can reject a transaction where one copy is fully consumed '
'in a transaction and a second copy is made', () async {
// Regression test for https://github.com/dart-lang/async/issues/229
final queue = StreamQueue(Stream.fromIterable([0]));
final transaction = queue.startTransaction();

final copy1 = transaction.newQueue();
final inner1 = copy1.startTransaction();
final innerCopy1 = inner1.newQueue();
await innerCopy1.next;

transaction.newQueue();

transaction.reject();
expect(await queue.next, 0);
expect(await queue.hasNext, isFalse);
}, skip: 'https://github.com/dart-lang/async/issues/229');
});

group('when committed', () {
Expand Down

0 comments on commit ce650b0

Please sign in to comment.