chore: bump dart sdk to 3.8 (#20355)

* chore: bump dart sdk to 3.8

* chore: make build

* make pigeon

* chore: format files

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-07-29 00:34:03 +05:30
committed by GitHub
parent 9b3718120b
commit e52b9d15b5
643 changed files with 32561 additions and 35292 deletions
@@ -12,48 +12,21 @@ void main() {
late MediumFactory mediumFactory;
setUp(() {
db = Drift(
DatabaseConnection(
NativeDatabase.memory(),
closeStreamsSynchronously: true,
),
);
db = Drift(DatabaseConnection(NativeDatabase.memory(), closeStreamsSynchronously: true));
mediumFactory = MediumFactory(db);
});
group('getAll', () {
test('sorts albums by backupSelection & isIosSharedAlbum', () async {
final localAlbumRepo = mediumFactory.getRepository<DriftLocalAlbumRepository>();
await localAlbumRepo.upsert(mediumFactory.localAlbum(id: '1', backupSelection: BackupSelection.none));
await localAlbumRepo.upsert(mediumFactory.localAlbum(id: '2', backupSelection: BackupSelection.excluded));
await localAlbumRepo.upsert(
mediumFactory.localAlbum(
id: '1',
backupSelection: BackupSelection.none,
),
);
await localAlbumRepo.upsert(
mediumFactory.localAlbum(
id: '2',
backupSelection: BackupSelection.excluded,
),
);
await localAlbumRepo.upsert(
mediumFactory.localAlbum(
id: '3',
backupSelection: BackupSelection.selected,
isIosSharedAlbum: true,
),
);
await localAlbumRepo.upsert(
mediumFactory.localAlbum(
id: '4',
backupSelection: BackupSelection.selected,
),
mediumFactory.localAlbum(id: '3', backupSelection: BackupSelection.selected, isIosSharedAlbum: true),
);
await localAlbumRepo.upsert(mediumFactory.localAlbum(id: '4', backupSelection: BackupSelection.selected));
final albums = await localAlbumRepo.getAll(
sortBy: {
SortLocalAlbumsBy.backupSelection,
SortLocalAlbumsBy.isIosSharedAlbum,
},
sortBy: {SortLocalAlbumsBy.backupSelection, SortLocalAlbumsBy.isIosSharedAlbum},
);
expect(albums.length, 4);
expect(albums[0].id, '4'); // selected
@@ -24,16 +24,8 @@ Future<void> _addStrStoreValue(Isar db, StoreKey key, String? value) async {
Future<void> _populateStore(Isar db) async {
await db.writeTxn(() async {
await _addIntStoreValue(
db,
StoreKey.colorfulInterface,
_kTestColorfulInterface ? 1 : 0,
);
await _addIntStoreValue(
db,
StoreKey.backupFailedSince,
_kTestBackupFailed.millisecondsSinceEpoch,
);
await _addIntStoreValue(db, StoreKey.colorfulInterface, _kTestColorfulInterface ? 1 : 0);
await _addIntStoreValue(db, StoreKey.backupFailedSince, _kTestBackupFailed.millisecondsSinceEpoch);
await _addStrStoreValue(db, StoreKey.accessToken, _kTestAccessToken);
await _addIntStoreValue(db, StoreKey.version, _kTestVersion);
});
@@ -143,21 +135,10 @@ void main() {
stream,
emitsInAnyOrder([
emits(const StoreDto<Object>(StoreKey.version, _kTestVersion)),
emits(
StoreDto<Object>(StoreKey.backupFailedSince, _kTestBackupFailed),
),
emits(
const StoreDto<Object>(StoreKey.accessToken, _kTestAccessToken),
),
emits(
const StoreDto<Object>(
StoreKey.colorfulInterface,
_kTestColorfulInterface,
),
),
emits(
const StoreDto<Object>(StoreKey.version, _kTestVersion + 10),
),
emits(StoreDto<Object>(StoreKey.backupFailedSince, _kTestBackupFailed)),
emits(const StoreDto<Object>(StoreKey.accessToken, _kTestAccessToken)),
emits(const StoreDto<Object>(StoreKey.colorfulInterface, _kTestColorfulInterface)),
emits(const StoreDto<Object>(StoreKey.version, _kTestVersion + 10)),
]),
);
await sut.update(StoreKey.version, _kTestVersion + 10);
@@ -63,14 +63,8 @@ void main() {
}
});
Future<void> streamChanges(
Function(List<SyncEvent>, Function() abort) onDataCallback,
) {
return sut.streamChanges(
onDataCallback,
batchSize: testBatchSize,
httpClient: mockHttpClient,
);
Future<void> streamChanges(Function(List<SyncEvent>, Function() abort) onDataCallback) {
return sut.streamChanges(onDataCallback, batchSize: testBatchSize, httpClient: mockHttpClient);
}
test('streamChanges stops processing stream when abort is called', () async {
@@ -96,11 +90,7 @@ void main() {
for (int i = 0; i < testBatchSize; i++) {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user$i").toJson(),
'ack$i',
),
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user$i").toJson(), 'ack$i'),
),
);
}
@@ -108,11 +98,7 @@ void main() {
for (int i = testBatchSize; i < testBatchSize * 2; i++) {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user$i").toJson(),
'ack$i',
),
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user$i").toJson(), 'ack$i'),
),
);
}
@@ -126,113 +112,91 @@ void main() {
verify(() => mockHttpClient.close()).called(1);
});
test(
'streamChanges does not process remaining lines in finally block if aborted',
() async {
int onDataCallCount = 0;
bool abortWasCalledInCallback = false;
test('streamChanges does not process remaining lines in finally block if aborted', () async {
int onDataCallCount = 0;
bool abortWasCalledInCallback = false;
onDataCallback(List<SyncEvent> events, Function() abort) {
onDataCallCount++;
if (onDataCallCount == 1) {
abort();
abortWasCalledInCallback = true;
} else {
fail("onData called more than once after abort was invoked");
}
onDataCallback(List<SyncEvent> events, Function() abort) {
onDataCallCount++;
if (onDataCallCount == 1) {
abort();
abortWasCalledInCallback = true;
} else {
fail("onData called more than once after abort was invoked");
}
}
final streamChangesFuture = streamChanges(onDataCallback);
final streamChangesFuture = streamChanges(onDataCallback);
await pumpEventQueue();
await pumpEventQueue();
for (int i = 0; i < testBatchSize; i++) {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user$i").toJson(),
'ack$i',
),
),
);
}
// emit a single event to skip batching and trigger finally
for (int i = 0; i < testBatchSize; i++) {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user100").toJson(),
'ack100',
),
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user$i").toJson(), 'ack$i'),
),
);
}
await responseStreamController.close();
await expectLater(streamChangesFuture, completes);
// emit a single event to skip batching and trigger finally
responseStreamController.add(
utf8.encode(
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user100").toJson(), 'ack100'),
),
);
expect(onDataCallCount, 1);
expect(abortWasCalledInCallback, isTrue);
verify(() => mockHttpClient.close()).called(1);
},
);
await responseStreamController.close();
await expectLater(streamChangesFuture, completes);
test(
'streamChanges processes remaining lines in finally block if not aborted',
() async {
int onDataCallCount = 0;
List<SyncEvent> receivedEventsBatch1 = [];
List<SyncEvent> receivedEventsBatch2 = [];
expect(onDataCallCount, 1);
expect(abortWasCalledInCallback, isTrue);
verify(() => mockHttpClient.close()).called(1);
});
onDataCallback(List<SyncEvent> events, Function() _) {
onDataCallCount++;
if (onDataCallCount == 1) {
receivedEventsBatch1 = events;
} else if (onDataCallCount == 2) {
receivedEventsBatch2 = events;
} else {
fail("onData called more than expected");
}
test('streamChanges processes remaining lines in finally block if not aborted', () async {
int onDataCallCount = 0;
List<SyncEvent> receivedEventsBatch1 = [];
List<SyncEvent> receivedEventsBatch2 = [];
onDataCallback(List<SyncEvent> events, Function() _) {
onDataCallCount++;
if (onDataCallCount == 1) {
receivedEventsBatch1 = events;
} else if (onDataCallCount == 2) {
receivedEventsBatch2 = events;
} else {
fail("onData called more than expected");
}
}
final streamChangesFuture = streamChanges(onDataCallback);
final streamChangesFuture = streamChanges(onDataCallback);
await pumpEventQueue();
await pumpEventQueue();
// Batch 1
for (int i = 0; i < testBatchSize; i++) {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user$i").toJson(),
'ack$i',
),
),
);
}
// Partial Batch 2
// Batch 1
for (int i = 0; i < testBatchSize; i++) {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user100").toJson(),
'ack100',
),
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user$i").toJson(), 'ack$i'),
),
);
}
await responseStreamController.close();
await expectLater(streamChangesFuture, completes);
// Partial Batch 2
responseStreamController.add(
utf8.encode(
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user100").toJson(), 'ack100'),
),
);
expect(onDataCallCount, 2);
expect(receivedEventsBatch1.length, testBatchSize);
expect(receivedEventsBatch2.length, 1);
verify(() => mockHttpClient.close()).called(1);
},
);
await responseStreamController.close();
await expectLater(streamChangesFuture, completes);
expect(onDataCallCount, 2);
expect(receivedEventsBatch1.length, testBatchSize);
expect(receivedEventsBatch2.length, 1);
verify(() => mockHttpClient.close()).called(1);
});
test('streamChanges handles stream error gracefully', () async {
final streamError = Exception("Network Error");
@@ -248,11 +212,7 @@ void main() {
responseStreamController.add(
utf8.encode(
_createJsonLine(
SyncEntityType.userDeleteV1.toString(),
SyncUserDeleteV1(userId: "user1").toJson(),
'ack1',
),
_createJsonLine(SyncEntityType.userDeleteV1.toString(), SyncUserDeleteV1(userId: "user1").toJson(), 'ack1'),
),
);