Test restored rides retain persisted cloud identity

This commit is contained in:
bponders12-cell 2026-09-01 21:06:09 -04:00
parent cf459e934a
commit cc84c8ff4f
1 changed files with 24 additions and 0 deletions

View File

@ -95,4 +95,28 @@ void main() {
final rideId = await db.startRide();
expect(await db.getCloudRideId(rideId), startsWith('ride_'));
});
test('a restored ride keeps its cloud identity even when its local ID changes', () async {
const cloudId = 'ride_9f4d8a3e2b1c7d6e5f4a3b2c1d0e9f8a';
final original = AppDatabase.forTesting(NativeDatabase.memory());
final restored = AppDatabase.forTesting(NativeDatabase.memory());
addTearDown(original.close);
addTearDown(restored.close);
final originalId = await original.startRide();
await original.customStatement(
'UPDATE rides SET cloud_ride_id = ? WHERE id = ?',
[cloudId, originalId],
);
expect(await original.getCloudRideId(originalId), cloudId);
final restoredId = await restored.startRide();
await restored.customStatement(
'UPDATE rides SET cloud_ride_id = ? WHERE id = ?',
[cloudId, restoredId],
);
expect(restoredId, isNot(originalId));
expect(await restored.getCloudRideId(restoredId), cloudId);
});
}