fix: improve transfer recognition and local data safety
This commit is contained in:
@@ -82,4 +82,29 @@ void main() {
|
||||
throwsStateError,
|
||||
);
|
||||
});
|
||||
|
||||
test('云端回写失败时保留待同步的本地账单', () {
|
||||
final database = LocalDatabase.inMemoryForTesting();
|
||||
addTearDown(database.close);
|
||||
final local = database.createTransaction({
|
||||
'ledgerId': 1,
|
||||
'categoryId': 1,
|
||||
'type': 'expense',
|
||||
'amount': 28,
|
||||
'occurredAt': '2026-07-25T03:00:00.000Z',
|
||||
'source': 'manual',
|
||||
});
|
||||
final localId = local['id'] as int;
|
||||
|
||||
expect(
|
||||
() => database.replaceLocalTransaction(localId, {
|
||||
...local,
|
||||
'id': 42,
|
||||
'occurredAt': 'invalid-time',
|
||||
}),
|
||||
throwsFormatException,
|
||||
);
|
||||
expect(database.transaction(localId), isNotNull);
|
||||
expect(database.transaction(42), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user