Test restored rides retain persisted cloud identity
This commit is contained in:
parent
cf459e934a
commit
cc84c8ff4f
|
|
@ -95,4 +95,28 @@ void main() {
|
||||||
final rideId = await db.startRide();
|
final rideId = await db.startRide();
|
||||||
expect(await db.getCloudRideId(rideId), startsWith('ride_'));
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue