Skip to content

Commit

Permalink
Merge pull request #1657 from famedly/krille/test-database-can-read-5-mb
Browse files Browse the repository at this point in the history
ci: Test that database can write and read at least 5mb of data
  • Loading branch information
krille-chan authored Dec 27, 2023
2 parents df035d8 + aa2b010 commit 263baa6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/database_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ import 'package:test/test.dart';
import 'package:matrix/matrix.dart';
import 'fake_database.dart';

String createLargeString(String character, int desiredSize) {
final buffer = StringBuffer();

while (buffer.length < desiredSize) {
buffer.write(character);
}

return buffer.toString();
}

void main() {
final databaseBuilders = {
'Matrix SDK Database': getMatrixSdkDatabase,
Expand Down Expand Up @@ -173,6 +183,21 @@ void main() {
expect(
events2.values.any((element) => element.type == 'm.abc+de'), true);
});
test('Database can write and read 5MB data', () async {
final hugeDataObject = {'foo': createLargeString('A', 5 * 1024 * 1024)};

await database.storeAccountData(
'm.huge_data_test',
jsonEncode(hugeDataObject),
);

final events = await database.getAccountData();

expect(
events.values.any((data) => data.type == 'm.huge_data_test'),
true,
);
});
test('storeEventUpdate', () async {
await database.storeEventUpdate(
EventUpdate(
Expand Down

0 comments on commit 263baa6

Please sign in to comment.