Skip to content

Commit

Permalink
refactor: general refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlala committed Jul 3, 2024
1 parent 5a7f507 commit 1adc9dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/alice/lib/core/alice_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:alice/core/alice_logger.dart';
import 'package:alice/core/alice_storage.dart';
import 'package:alice/core/alice_utils.dart';
import 'package:alice/helper/alice_export_helper.dart';
import 'package:alice/core/alice_notification_helper.dart';
import 'package:alice/core/alice_notification.dart';
import 'package:alice/helper/operating_system.dart';
import 'package:alice/model/alice_export_result.dart';
import 'package:alice/model/alice_http_call.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void main() {
expect(result.error, null);

final file = File(result.path!);
expect(file.existsSync(), true);
final content = await file.readAsString();
_verifyLogLines(content);
file.delete();
Expand All @@ -60,7 +61,8 @@ void main() {

test("should not save call log to file if file problem occurs", () async {
TestWidgetsFlutterBinding.ensureInitialized();
_setPathProvider();
_setPackageInfo();
_setPathProvider(isFailing: true);
_setDefaultTargetPlatform();

final result = await AliceExportHelper.saveCallsToFile(
Expand Down Expand Up @@ -146,12 +148,16 @@ void _setPackageInfo() {
);
}

void _setPathProvider() {
void _setPathProvider({bool isFailing = false}) {
const MethodChannel channel =
MethodChannel('plugins.flutter.io/path_provider');
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
return ".";
if (isFailing) {
return "";
} else {
return ".";
}
});
}

Expand Down

0 comments on commit 1adc9dd

Please sign in to comment.