lundi 5 avril 2021

Test failed to load while creating a Store

I try to unit-test, but it fails to load:

dart:ffi                                                                                                         new DynamicLibrary.open
package:objectbox/src/native/bindings/bindings.dart 21:28                                                        loadObjectBoxLib
package:objectbox/src/native/bindings/bindings.dart 50:41                                                        C
package:objectbox/src/native/model.dart 18:31                                                                    new Model
package:objectbox/src/native/store.dart 63:17                                                                    new Store
package:productivitie/features/to_do_listing/data/datasource/project_database_data_source_object_box.dart 23:15  new ProjectDataBaseDataSourceObjectBox.<fn>
dart:async                                                                                                       _completeOnAsyncReturn
package:path_provider/path_provider.dart                                                                         getApplicationDocumentsDirectory

Failed to load "F:\Programme\gitProgramme\productivitie\test\features\to_do_listing\data\datasource\project_database_data_source_object_box_test.dart": Invalid argument(s): Failed to load dynamic library (193)

My Constructor, where the problem occours:

21 ProjectDataBaseDataSourceObjectBox(){
22    getApplicationDocumentsDirectory().then((Directory dir){
23      store = Store(getObjectBoxModel() , directory: dir.path + '/objectbox' );
24      box = store!.box<Project>();
25    });
26
27  }

Flutter Doctor found no issues. I build_run my models again (overwrote objectbox.g.dart file), didn't help. My versions are:

 objectbox: 0.14.0
  objectbox_flutter_libs: any
  path_provider: ^2.0.1

I first thought it was a problem with the path_provider, I did set a MockMethodCallHandler to return a mocked directory path if the path_provider tries to getApplicationDocumentsDirectory.

final directory = await Directory.systemTemp.createTemp();

      const MethodChannel('plugins.flutter.io/path_provider').setMockMethodCallHandler((MethodCall call) async {
        if(call.method == 'getApplicationDocumentsDirectory'){
          return directory.path;
        }
        return null;
      });

But that didn't help either.

Aucun commentaire:

Enregistrer un commentaire