mirror of https://github.com/AMT-Cheif/drift.git
Add small integration test for generated upserts
This commit is contained in:
parent
d2e455d66b
commit
1da09e7357
|
@ -0,0 +1,27 @@
|
|||
import 'package:moor/moor.dart';
|
||||
import 'package:moor_ffi/moor_ffi.dart';
|
||||
@TestOn('vm')
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../data/tables/todos.dart';
|
||||
|
||||
void main() {
|
||||
TodoDb db;
|
||||
|
||||
setUp(() {
|
||||
db = TodoDb(VmDatabase.memory());
|
||||
});
|
||||
|
||||
test('insertOnConflictUpdate', () async {
|
||||
await db.into(db.categories).insert(
|
||||
CategoriesCompanion.insert(description: 'original description'));
|
||||
|
||||
var row = await db.select(db.categories).getSingle();
|
||||
|
||||
await db.into(db.categories).insertOnConflictUpdate(CategoriesCompanion(
|
||||
id: Value(row.id), description: const Value('changed description')));
|
||||
|
||||
row = await db.select(db.categories).getSingle();
|
||||
expect(row.description, 'changed description');
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue