Unit tests for row.read*

This commit is contained in:
Simon Binder 2019-09-29 16:33:09 +02:00
parent 4137f6cffa
commit 869aaada90
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
1 changed files with 26 additions and 0 deletions

View File

@ -29,6 +29,32 @@ void main() {
}); });
}); });
test('custom select reads values', () async {
final time = DateTime(2019, 10, 1);
final unix = time.millisecondsSinceEpoch ~/ 1000;
when(executor.runSelect(any, any)).thenAnswer((i) {
return Future.value([
<String, dynamic>{
'bool': true,
'int': 3,
'double': 3.14,
'dateTime': unix,
'blob': Uint8List.fromList([1, 2, 3]),
}
]);
});
final rows = await db.customSelectQuery('').get();
final row = rows.single;
expect(row.readBool('bool'), isTrue);
expect(row.readInt('int'), 3);
expect(row.readDouble('double'), 3.14);
expect(row.readDateTime('dateTime'), time);
expect(row.readBlob('blob'), Uint8List.fromList([1, 2, 3]));
});
test('custom update informs stream queries', () async { test('custom update informs stream queries', () async {
await db.customUpdate('UPDATE tbl SET a = ?', await db.customUpdate('UPDATE tbl SET a = ?',
variables: [Variable.withString('hi')], updates: {db.users}); variables: [Variable.withString('hi')], updates: {db.users});