File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
packages/sqlite_async/test Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import 'dart:async';
55import 'dart:isolate' ;
66import 'dart:math' ;
77
8+ import 'package:async/async.dart' ;
89import 'package:sqlite3/common.dart' ;
910import 'package:sqlite_async/native.dart' ;
1011import 'package:sqlite_async/sqlite_async.dart' ;
@@ -25,6 +26,16 @@ void main() {
2526 await testUtils.cleanDb (path: path);
2627 });
2728
29+ test ('emits updates if stream is listened to before pool is opened' ,
30+ () async {
31+ final db = await testUtils.setupDatabase ();
32+ final updates = StreamQueue (db.updates);
33+
34+ await db.execute ('CREATE TABLE a (bar INTEGER);' );
35+ await db.execute ('INSERT INTO a DEFAULT VALUES' );
36+ await expectLater (updates, emits (UpdateNotification ({'a' })));
37+ });
38+
2839 test ('raw update notifications' , () async {
2940 final factory =
3041 (await testUtils.testFactory (path: path)) as NativeSqliteOpenFactory ;
Original file line number Diff line number Diff line change @@ -31,6 +31,19 @@ void main() {
3131 await testUtils.cleanDb (path: path);
3232 });
3333
34+ test ('is broadcast stream' , () async {
35+ final db = await testUtils.setupDatabase (path: path);
36+ await createTables (db);
37+
38+ expect (db.updates.isBroadcast, isTrue);
39+ var events = 0 ;
40+
41+ db.updates.listen ((_) => events++ );
42+ db.updates.listen ((_) => events++ );
43+ await db.execute ('INSERT INTO assets DEFAULT VALUES' );
44+ expect (events, 2 );
45+ });
46+
3447 test ('watch' , () async {
3548 final db = await testUtils.setupDatabase (path: path);
3649 await createTables (db);
You can’t perform that action at this time.
0 commit comments