fixed tests
This commit is contained in:
parent
b012fc9ff5
commit
49b957faea
3 changed files with 15 additions and 9 deletions
|
@ -4,12 +4,10 @@ import 'package:collection/collection.dart';
|
||||||
import 'package:test/fake.dart';
|
import 'package:test/fake.dart';
|
||||||
|
|
||||||
class FakeMediaFetchService extends Fake implements MediaFetchService {
|
class FakeMediaFetchService extends Fake implements MediaFetchService {
|
||||||
Duration latency = Duration.zero;
|
|
||||||
Set<AvesEntry> entries = {};
|
Set<AvesEntry> entries = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<AvesEntry?> getEntry(String uri, String? mimeType) async {
|
Future<AvesEntry?> getEntry(String uri, String? mimeType) async {
|
||||||
await Future.delayed(latency);
|
|
||||||
return entries.firstWhereOrNull((v) => v.uri == uri);
|
return entries.firstWhereOrNull((v) => v.uri == uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,23 @@ import 'package:aves/services/media/media_store_service.dart';
|
||||||
import 'package:test/fake.dart';
|
import 'package:test/fake.dart';
|
||||||
|
|
||||||
class FakeMediaStoreService extends Fake implements MediaStoreService {
|
class FakeMediaStoreService extends Fake implements MediaStoreService {
|
||||||
Duration latency = Duration.zero;
|
late Set<AvesEntry> entries;
|
||||||
Set<AvesEntry> entries = {};
|
Duration? latency;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
entries = {};
|
||||||
|
latency = null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<int>> checkObsoleteContentIds(List<int?> knownContentIds) async {
|
Future<List<int>> checkObsoleteContentIds(List<int?> knownContentIds) async {
|
||||||
await Future.delayed(latency);
|
if (latency != null) await Future.delayed(latency!);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<int>> checkObsoletePaths(Map<int?, String?> knownPathById) async {
|
Future<List<int>> checkObsoletePaths(Map<int?, String?> knownPathById) async {
|
||||||
await Future.delayed(latency);
|
if (latency != null) await Future.delayed(latency!);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ void main() {
|
||||||
countryName: 'AUS',
|
countryName: 'AUS',
|
||||||
);
|
);
|
||||||
|
|
||||||
setUp(() async {
|
setUpAll(() async {
|
||||||
// specify Posix style path context for consistent behaviour when running tests on Windows
|
// specify Posix style path context for consistent behaviour when running tests on Windows
|
||||||
getIt.registerLazySingleton<p.Context>(() => p.Context(style: p.Style.posix));
|
getIt.registerLazySingleton<p.Context>(() => p.Context(style: p.Style.posix));
|
||||||
getIt.registerLazySingleton<AvesAvailability>(FakeAvesAvailability.new);
|
getIt.registerLazySingleton<AvesAvailability>(FakeAvesAvailability.new);
|
||||||
|
@ -71,7 +71,11 @@ void main() {
|
||||||
await androidFileUtils.init();
|
await androidFileUtils.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() async {
|
setUp(() async {
|
||||||
|
(getIt<MediaStoreService>() as FakeMediaStoreService).reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
tearDownAll(() async {
|
||||||
await getIt.reset();
|
await getIt.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -360,7 +364,6 @@ void main() {
|
||||||
FakeMediaStoreService.newImage('${FakeStorageService.primaryPath}Pictures/Arendt', '1'),
|
FakeMediaStoreService.newImage('${FakeStorageService.primaryPath}Pictures/Arendt', '1'),
|
||||||
};
|
};
|
||||||
|
|
||||||
await androidFileUtils.init();
|
|
||||||
final source = await _initSource();
|
final source = await _initSource();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Builder(
|
Builder(
|
||||||
|
|
Loading…
Reference in a new issue