refactor: Switch to MatrixSdkDatabase as suggested database and deprecate other ones

This commit is contained in:
Krille 2024-03-22 15:56:57 +01:00
parent 8b2b8642b4
commit e266ef7312
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
9 changed files with 20 additions and 9 deletions

View File

@ -60,7 +60,7 @@ jobs:
sdk: ${{ env.dart_version }}
- name: Run tests
run: |
apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-dev
apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-0 libsqlite3-dev
curl -o /bin/lcov_cobertura.py https://raw.githubusercontent.com/eriwen/lcov-to-cobertura-xml/master/lcov_cobertura/lcov_cobertura.py && sed 's/env python/env python3/' -i /bin/lcov_cobertura.py && chmod +x /bin/lcov_cobertura.py
dart pub get
./scripts/test.sh

View File

@ -34,6 +34,8 @@ import 'package:matrix/src/utils/queued_to_device_event.dart';
import 'package:matrix/src/utils/run_benchmarked.dart';
/// This database does not support file caching!
@Deprecated(
'Use [MatrixSdkDatabase] instead. Don\'t forget to properly migrate!')
class HiveCollectionsDatabase extends DatabaseApi {
static const int version = 7;
final String name;

View File

@ -39,7 +39,7 @@ import 'package:matrix/src/utils/run_benchmarked.dart';
///
/// This database does not support file caching!
@Deprecated(
'Use [HiveCollectionsDatabase] instead. Don\'t forget to properly migrate!')
'Use [MatrixSdkDatabase] instead. Don\'t forget to properly migrate!')
class FamedlySdkHiveDatabase extends DatabaseApi with ZoneTransactionMixin {
static const int version = 6;
final String name;

View File

@ -39,7 +39,7 @@ dev_dependencies:
file: ">=6.1.1 <8.0.0"
import_sorter: ^4.6.0
lints: ^3.0.0
sqflite_common_ffi: ^2.2.5
sqflite_common_ffi: ^2.3.3
test: ^1.15.7
#flutter_test: {sdk: flutter}
#dependency_overrides:

View File

@ -1,2 +1,2 @@
#!/usr/bin/env bash
apk update && apk add docker drill grep olm cmake
apk update && apk add docker drill grep olm cmake sqlite-dev

View File

@ -155,7 +155,11 @@ void main() {
expect(presenceCounter, 1);
expect(accountDataCounter, 10);
await Future.delayed(Duration(milliseconds: 50));
expect(matrix.userDeviceKeys.length, 4);
expect(matrix.userDeviceKeys.keys.toSet(), {
'@alice:example.com',
'@othertest:fakeServer.notExisting',
'@test:fakeServer.notExisting',
});
expect(matrix.userDeviceKeys['@alice:example.com']?.outdated, false);
expect(matrix.userDeviceKeys['@alice:example.com']?.deviceKeys.length, 2);
expect(

View File

@ -22,10 +22,11 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:matrix/matrix.dart';
Future<DatabaseApi> getDatabase(Client? _) => getHiveCollectionsDatabase(_);
Future<DatabaseApi> getDatabase(Client? _) => getMatrixSdkDatabase(_);
bool hiveInitialized = false;
// ignore: deprecated_member_use_from_same_package
Future<HiveCollectionsDatabase> getHiveCollectionsDatabase(Client? c) async {
final testHivePath = await LocalFileSystem()
.systemTempDirectory
@ -33,6 +34,7 @@ Future<HiveCollectionsDatabase> getHiveCollectionsDatabase(Client? c) async {
if (!hiveInitialized) {
Hive.init(testHivePath.path);
}
// ignore: deprecated_member_use_from_same_package
final db = HiveCollectionsDatabase(
'unit_test.${c?.hashCode}',
testHivePath.path,
@ -43,7 +45,10 @@ Future<HiveCollectionsDatabase> getHiveCollectionsDatabase(Client? c) async {
// ignore: deprecated_member_use_from_same_package
Future<MatrixSdkDatabase> getMatrixSdkDatabase(Client? c) async {
final database = await databaseFactoryFfi.openDatabase(':memory:');
final database = await databaseFactoryFfi.openDatabase(
':memory:',
options: OpenDatabaseOptions(singleInstance: false),
);
final db = MatrixSdkDatabase(
'unit_test.${c?.hashCode}',
database: database,

View File

@ -1735,7 +1735,7 @@ class FakeMatrixApi extends BaseClient {
}
]
},
'/client/v3/rooms/!726s6s6q:example.com/members': (var req) => {
'/client/v3/rooms/!726s6s6q%3Aexample.com/members': (var req) => {
'chunk': [
{
'content': {

View File

@ -454,7 +454,7 @@ void main() {
'sender': '@test:example.com',
'redacts': '9',
'event_id': '10',
'origin_server_ts': DateTime.now(),
'origin_server_ts': DateTime.now().millisecondsSinceEpoch,
},
stateKey: '',
),