mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-24 01:08:09 +08:00

Instead we're going to move back to standard exceptions. Using a custom Result class has created far far more problems - The Stacktraces aren't always right - Sometimes one forgets to check the Result error - All other exception throwing code needing to be converted to Results - Non idiomatic Dart code I think it's better to just go back to exceptions. They have their problems, but overall, I think it's a better approach.
81 lines
2.1 KiB
Dart
81 lines
2.1 KiB
Dart
/*
|
|
* SPDX-FileCopyrightText: 2019-2021 Vishesh Handa <me@vhanda.in>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
// ignore_for_file: invalid_use_of_visible_for_testing_member
|
|
// ignore_for_file: depend_on_referenced_packages
|
|
|
|
import 'package:path/path.dart';
|
|
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
|
|
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
|
import 'package:test/fake.dart';
|
|
import 'package:universal_io/io.dart';
|
|
|
|
// from path_provider_test
|
|
const String kTemporaryPath = 'temporaryPath';
|
|
const String kApplicationSupportPath = 'applicationSupportPath';
|
|
const String kDownloadsPath = 'downloadsPath';
|
|
const String kLibraryPath = 'libraryPath';
|
|
const String kApplicationDocumentsPath = 'applicationDocumentsPath';
|
|
const String kExternalCachePath = 'externalCachePath';
|
|
const String kExternalStoragePath = 'externalStoragePath';
|
|
|
|
class FakePathProviderPlatform extends Fake
|
|
with MockPlatformInterfaceMixin
|
|
implements PathProviderPlatform {
|
|
final Directory dir;
|
|
|
|
FakePathProviderPlatform(this.dir);
|
|
|
|
static Future<FakePathProviderPlatform> init() async {
|
|
var dir = await Directory.systemTemp.createTemp();
|
|
await Directory(join(dir.path, kTemporaryPath)).create();
|
|
|
|
return FakePathProviderPlatform(dir);
|
|
}
|
|
|
|
@override
|
|
Future<String?> getTemporaryPath() async {
|
|
return join(dir.path, kTemporaryPath);
|
|
}
|
|
|
|
@override
|
|
Future<String?> getApplicationSupportPath() async {
|
|
return kApplicationSupportPath;
|
|
}
|
|
|
|
@override
|
|
Future<String?> getLibraryPath() async {
|
|
return kLibraryPath;
|
|
}
|
|
|
|
@override
|
|
Future<String?> getApplicationDocumentsPath() async {
|
|
return kApplicationDocumentsPath;
|
|
}
|
|
|
|
@override
|
|
Future<String?> getExternalStoragePath() async {
|
|
return kExternalStoragePath;
|
|
}
|
|
|
|
@override
|
|
Future<List<String>?> getExternalCachePaths() async {
|
|
return <String>[kExternalCachePath];
|
|
}
|
|
|
|
@override
|
|
Future<List<String>?> getExternalStoragePaths({
|
|
StorageDirectory? type,
|
|
}) async {
|
|
return <String>[kExternalStoragePath];
|
|
}
|
|
|
|
@override
|
|
Future<String?> getDownloadsPath() async {
|
|
return kDownloadsPath;
|
|
}
|
|
}
|