|
| 1 | +import 'dart:async'; |
| 2 | + |
1 | 3 | import 'package:postgres/postgres.dart';
|
2 | 4 | import 'package:test/test.dart';
|
3 | 5 |
|
@@ -92,36 +94,54 @@ void main() {
|
92 | 94 | }
|
93 | 95 |
|
94 | 96 | withPostgresServer('connection session', (server) {
|
95 |
| - test('', () async { |
| 97 | + test('connection session', () async { |
96 | 98 | final conn = await openConnection(server);
|
97 |
| - // ignore: unawaited_futures |
98 |
| - runLongQuery(conn); |
| 99 | + final rs = runLongQuery(conn); |
99 | 100 | // let it start
|
100 | 101 | await Future.delayed(const Duration(milliseconds: 100));
|
101 | 102 | await expectConn1ClosesForcefully(conn);
|
| 103 | + |
| 104 | + // TODO: this should be throwing PgException |
| 105 | + await expectLater(() => rs, isNotNull); |
102 | 106 | });
|
103 | 107 | });
|
104 | 108 |
|
105 | 109 | withPostgresServer('tx session', (server) {
|
106 |
| - test('', () async { |
| 110 | + test('tx', () async { |
107 | 111 | final conn = await openConnection(server);
|
108 |
| - // ignore: unawaited_futures |
109 |
| - // Ignore async error, it will fail when the connection is closed and it tries to do COMMIT |
110 |
| - conn.runTx(runLongQuery).ignore(); |
| 112 | + final started = Completer(); |
| 113 | + final rs = conn.runTx((tx) async { |
| 114 | + started.complete(); |
| 115 | + await runLongQuery(tx); |
| 116 | + }) |
| 117 | + // Ignore async error, it will fail when the connection is closed and it tries to do COMMIT |
| 118 | + // TODO: remove this ignore |
| 119 | + .ignore(); |
111 | 120 | // let it start
|
| 121 | + await started.future; |
112 | 122 | await Future.delayed(const Duration(milliseconds: 100));
|
113 | 123 | await expectConn1ClosesForcefully(conn);
|
| 124 | + |
| 125 | + // TODO: this should be throwing PgException |
| 126 | + await expectLater(() => rs, isNotNull); |
114 | 127 | });
|
115 | 128 | });
|
116 | 129 |
|
117 | 130 | withPostgresServer('run session', (server) {
|
118 |
| - test('', () async { |
| 131 | + test('run', () async { |
119 | 132 | final conn = await openConnection(server);
|
120 |
| - // ignore: unawaited_futures |
121 |
| - conn.run(runLongQuery); |
| 133 | + final started = Completer(); |
| 134 | + final rs = conn.run((s) async { |
| 135 | + started.complete(); |
| 136 | + await runLongQuery(s); |
| 137 | + }); |
122 | 138 | // let it start
|
| 139 | + await started.future; |
123 | 140 | await Future.delayed(const Duration(milliseconds: 100));
|
124 | 141 | await expectConn1ClosesForcefully(conn);
|
| 142 | + |
| 143 | + // TODO: this should be throwing PgException |
| 144 | + await expectLater(() => rs, isNotNull); |
125 | 145 | });
|
126 | 146 | });
|
127 | 147 | });
|
|
0 commit comments