Skip to content

Commit 221cbed

Browse files
committed
test: cleanup temp app dir after DB concurrency tests
1 parent 745786f commit 221cbed

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

integration_test/components/fake_app_path.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ class FakeAppPath implements AppPath {
2626

2727
@override
2828
String get mediaCacheBasePath => '$temporaryPath/media_cache';
29+
30+
/// Deletes the temporary directory and all its contents.
31+
void cleanup() {
32+
if (_root.existsSync()) {
33+
try {
34+
_root.deleteSync(recursive: true);
35+
} catch (_) {
36+
// Ignore errors if file is locked
37+
}
38+
}
39+
}
2940
}

integration_test/database_concurrency_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const _targetNumber = 'SHARED-NUMBER';
2222
/// (Main UI Isolate and Background Isolate).
2323
void main() {
2424
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
25-
final fakeAppPath = FakeAppPath();
25+
26+
late FakeAppPath fakeAppPath;
2627

2728
group('Database Concurrency & Locking Tests', () {
2829
late String dbPath;
@@ -31,6 +32,7 @@ void main() {
3132
late CallLogsRepository mainRepository;
3233

3334
setUp(() async {
35+
fakeAppPath = FakeAppPath();
3436
dbPath = fakeAppPath.applicationDocumentsPath;
3537
dbName = 'test_db.sqlite';
3638

@@ -44,6 +46,7 @@ void main() {
4446
tearDown(() async {
4547
await mainDb.close();
4648
await DatabaseFileHelper.deleteDatabaseFiles(directoryPath: dbPath, dbName: dbName);
49+
fakeAppPath.cleanup();
4750
});
4851

4952
testWidgets(

0 commit comments

Comments
 (0)