Skip to content

Commit

Permalink
. r check current default path of VS code
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed May 17, 2024
1 parent b34c739 commit fe66aa9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
5 changes: 3 additions & 2 deletions lib/src/reporters/diff_tool/diff_tool_reporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ class DiffReporter implements Reporter {
}
if (e is ProcessException) {
ApprovalLogger.exception(e, stackTrace: st);
final ProcessResult result = await Process.run('which', ['code']);
ApprovalLogger.log('Path to Visual Studio Code: ${result.stdout}');
throw ProcessException(
'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.',
[diffInfo.arg],
);
}
throw IDEComparatorException(
message:
'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.',
message: 'Error during comparison via ${ide.name}. Please try check path to IDE. \n Current path: ${diffInfo.command}.',
exception: e,
stackTrace: st,
);
Expand Down
63 changes: 27 additions & 36 deletions test/approval_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ void main() {
);
});

test("Method «verify» must throw DoesntMatchException with error handling",
() {
test("Method «verify» must throw DoesntMatchException with error handling", () {
expect(
() => helper.verify(
'Hello W0rld',
Expand All @@ -116,9 +115,7 @@ void main() {
ApprovalLogger.log("$lines25 Group: Minor cases are starting $lines25");
});

test(
'Simulate file not found error during comparison. Must throw CommandLineComparatorException.',
() async {
test('Simulate file not found error during comparison. Must throw CommandLineComparatorException.', () async {
const comparator = FileComparator();

// Setup: paths to non-existent files
Expand All @@ -139,9 +136,7 @@ void main() {
);
});

test(
'Simulate file not found error during comparison. Must throw IDEComparatorException.',
() async {
test('Simulate file not found error during comparison. Must throw IDEComparatorException.', () async {
const reporter = DiffReporter();

// Setup: paths to non-existent files
Expand Down Expand Up @@ -178,34 +173,30 @@ void main() {
);
});

if (Platform.isLinux) {
test(
'Verify string with DiffReporter. Must throw IDEComparatorException.',
() async {
const reporter = DiffReporter(
customDiffInfo: LinuxDiffTools.visualStudioCode,
);

// Setup: paths to non-existent files
const nonExistentApprovedPath =
'test/approved_files/approval_test.verify.approved.txt';
const nonExistentReceivedPath =
'test/approved_files/approval_test.verify.received.txt';

// Expect an exception to be thrown
expect(
() => reporter.report(
nonExistentApprovedPath,
nonExistentReceivedPath,
),
throwsA(isA<ProcessException>()),
);

ApprovalLogger.success(
"Test Passed: Successfully handled a file not found error during comparison.",
);
});
}
// if (Platform.isLinux) {
test('Verify string with DiffReporter. Must throw IDEComparatorException.', () async {
const reporter = DiffReporter(
customDiffInfo: LinuxDiffTools.visualStudioCode,
);

// Setup: paths to non-existent files
const nonExistentApprovedPath = 'test/approved_files/approval_test.verify.approved.txt';
const nonExistentReceivedPath = 'test/approved_files/approval_test.verify.received.txt';

// Expect an exception to be thrown
expect(
() => reporter.report(
nonExistentApprovedPath,
nonExistentReceivedPath,
),
throwsA(isA<ProcessException>()),
);

ApprovalLogger.success(
"Test Passed: Successfully handled a file not found error during comparison.",
);
});
// }

test('Verify string with scrubber', () {
helper.verify(
Expand Down

0 comments on commit fe66aa9

Please sign in to comment.