I am trying to run CRUD tests in Flutter application. The local database that I am using is Isar database. It seems that application does not have rights to use Isar in Windows. However, example test runs smoothly with MacOS. Does anyone have had a similiar problem?
Test file:
import 'dart:io';
import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter_pill_cabinet/layers/data/models/reminder.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:isar/isar.dart';
// ignore: depend_on_referenced_packages
import 'package:path/path.dart' as path;
// Helper Methods for configuring the tests
String? testTempPath;
String getRandomName() {
var random = Random().nextInt(pow(2, 32) as int).toString();
return '${random}_tmp';
}
Future<Isar> openTempIsar(List<CollectionSchema<dynamic>> schemas,
{String? name}) async {
final dartToolDir = path.join(Directory.current.path, '.dart_tool');
testTempPath = path.join(dartToolDir, 'test', 'tmp');
return Isar.open(
schemas: schemas,
name: name ?? getRandomName(),
directory: kIsWeb ? '' : testTempPath!,
);
}
void main() {
group('Isar Experiment', () {
late Isar isar;
setUp(() async {
await Isar.initializeIsarCore(download: true);
isar = await openTempIsar(
[ReminderSchema],
);
});
test('Isar Test', () {
assert(1 == 1);
});
tearDown(() {
isar.close(deleteFromDisk: true);
});
});
}
The main error:
FileSystemException: Cannot open file, path = '\isar.dll' (OS Error: Access denied.
, errno = 5)