Browse Source

fix history test.

null-safety
Herbert Poul 4 years ago
parent
commit
7b83648755
  1. 18
      test/kdbx_history_test.dart

18
test/kdbx_history_test.dart

@ -23,7 +23,7 @@ class StreamExpect<T> {
});
}
Future<RET> expectNext<RET>(T value, FutureOr<RET>? Function() cb) async {
Future<RET> expectNext<RET>(T value, FutureOr<RET> Function() cb) async {
if (_expectNext != null) {
fail('The last event was never received. last: $_expectNext');
}
@ -58,30 +58,30 @@ void main() {
final first = file.body.rootGroup.entries.first;
expect(file.header.version.major, 3);
expect(first.getString(TestUtil.keyTitle)!.getText(), valueOrig);
await dirtyExpect.expectNext({first}, () {
await dirtyExpect.expectNext({first}, () async {
first.setString(TestUtil.keyTitle, PlainValue(value1));
});
}
expect(file.dirtyObjects, hasLength(1));
final f2 =
await dirtyExpect.expectNext({}, () => TestUtil.saveAndRead(file));
final f2 = await dirtyExpect
.expectNext({}, () async => TestUtil.saveAndRead(file));
expect(file.dirtyObjects, isEmpty);
{
final first = f2.body.rootGroup.entries.first;
expect(first.getString(TestUtil.keyTitle)!.getText(), value1);
expect(first.history.last.getString(TestUtil.keyTitle)!.getText(),
valueOrig);
await dirtyExpect.expectNext({}, () => file.save());
await dirtyExpect.expectNext({}, () async => file.save());
}
// edit the original file again, and there should be a second history
{
final first = file.body.rootGroup.entries.first;
await dirtyExpect.expectNext({first},
() => first.setString(TestUtil.keyTitle, PlainValue(value2)));
() async => first.setString(TestUtil.keyTitle, PlainValue(value2)));
}
final f3 =
await dirtyExpect.expectNext({}, () => TestUtil.saveAndRead(file));
final f3 = await dirtyExpect
.expectNext({}, () async => TestUtil.saveAndRead(file));
expect(file.dirtyObjects, isEmpty);
{
final first = f3.body.rootGroup.entries.first;
@ -91,7 +91,7 @@ void main() {
first.history.last.getString(TestUtil.keyTitle)!.getText(), value1);
expect(first.history.first.getString(TestUtil.keyTitle)!.getText(),
valueOrig);
await dirtyExpect.expectNext({}, () => file.save());
await dirtyExpect.expectNext({}, () async => file.save());
}
file.dispose();
await pumpEventQueue();

Loading…
Cancel
Save