2020-11-18 08:07:05 -08:00
|
|
|
@TestOn('vm')
|
2020-04-20 13:03:45 -07:00
|
|
|
import 'package:moor/moor.dart';
|
2020-07-08 10:04:57 -07:00
|
|
|
import 'package:moor/ffi.dart';
|
2020-04-20 13:03:45 -07:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
import '../data/tables/todos.dart';
|
|
|
|
|
|
|
|
void main() {
|
2021-01-20 03:30:59 -08:00
|
|
|
late TodoDb db;
|
2020-04-20 13:03:45 -07:00
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
}
|