-
-
Notifications
You must be signed in to change notification settings - Fork 500
Expand file tree
/
Copy pathtest_configuration.dart
More file actions
36 lines (31 loc) · 949 Bytes
/
test_configuration.dart
File metadata and controls
36 lines (31 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import 'package:file/file.dart' show File;
import 'package:file/memory.dart';
import 'package:flutter_cache_manager/src/config/config.dart';
import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart';
import 'mock_cache_info_repository.dart';
import 'mock_file_service.dart';
Config createTestConfig() {
return Config(
'test',
fileSystem: TestFileSystem(),
repo: MockCacheInfoRepository(),
fileService: MockFileService(),
);
}
class TestFileSystem extends FileSystem {
final directoryFuture =
MemoryFileSystem().systemTempDirectory.createTemp('test');
@override
Future<File> createFile(String name) async {
var dir = await directoryFuture;
await dir.create(recursive: true);
return dir.childFile(name);
}
@override
Future<void> deleteCacheDir() async {
var dir = await directoryFuture;
if (await dir.exists()) {
await dir.delete(recursive: true);
}
}
}