Skip to content

Commit

Permalink
. r changed diff tools path to snap
Browse files Browse the repository at this point in the history
  • Loading branch information
yelmuratoff committed May 18, 2024
1 parent 2d0e240 commit b179a26
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
1 change: 1 addition & 0 deletions form.docx

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions lib/src/reporters/diff_tool/diff_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ part of '../../../../approval_tests.dart';
/// `MacDiffTools` contains diff tools available on macOS.
final class MacDiffTools {
static const DiffInfo visualStudioCode = DiffInfo(
command:
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
command: '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
arg: '-d',
);

Expand Down Expand Up @@ -32,13 +31,13 @@ final class WindowsDiffTools {
final class LinuxDiffTools {
// TODO: check correct path for Visual Studio Code on Linux
static const DiffInfo visualStudioCode = DiffInfo(
command: '/usr/bin/code',
command: '/snap/bin/code',
arg: '-d',
);

// TODO: check correct path for Android Studio on Linux
static const DiffInfo androidStudio = DiffInfo(
command: '/usr/bin/studio',
command: '/snap/bin/studio',
arg: 'diff',
);
}
12 changes: 8 additions & 4 deletions test/groups/diff_tools_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ void diffToolsTests({
);

// Setup: paths to existent files
const existentApprovedPath = 'test/approved_files/approval_test.verify.approved.txt';
const existentReceivedPath = 'test/approved_files/approval_test.verify.received.txt';
const existentApprovedPath =
'test/approved_files/approval_test.verify.approved.txt';
const existentReceivedPath =
'test/approved_files/approval_test.verify.received.txt';

// Expect an exception to be thrown
expect(
Expand All @@ -41,8 +43,10 @@ void diffToolsTests({
);

// Setup: paths to existent files
const existentApprovedPath = 'test/approved_files/approval_test.verify.approved.txt';
const existentReceivedPath = 'test/approved_files/approval_test.verify.received.txt';
const existentApprovedPath =
'test/approved_files/approval_test.verify.approved.txt';
const existentReceivedPath =
'test/approved_files/approval_test.verify.received.txt';

// Expect an exception to be thrown
expect(
Expand Down
3 changes: 2 additions & 1 deletion test/groups/exception_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void exceptionTests({
);
});

test("Method «verify» must throw DoesntMatchException with error handling", () {
test("Method «verify» must throw DoesntMatchException with error handling",
() {
expect(
() => helper.verify(
'Hello W0rld',
Expand Down
41 changes: 34 additions & 7 deletions test/groups/minor_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ void minorTests({
ApprovalLogger.log("$lines25 Group: Minor tests are starting $lines25");
});

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

// Setup: paths to non-existent files
Expand All @@ -31,7 +33,9 @@ void minorTests({
);
});

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 @@ -68,15 +72,36 @@ void minorTests({
);
});

test('verify string with Android Studio DiffReporter', () {
expect(
() => helper.verify(
'Hello W0rld',
'verify',
deleteReceivedFile: false,
reporter: const DiffReporter(
ide: ComparatorIDE.studio,
),
),
throwsA(isA<DoesntMatchException>()),
);

ApprovalLogger.success(
"Test Passed: Successfully handled a log mismatch. Method «verify» correctly throws DoesntMatchException as expected.",
);
});

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

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

// Expect an exception to be thrown
expect(
Expand Down Expand Up @@ -126,7 +151,8 @@ void minorTests({
'file:///path/to/file.dart:10:11\nother stack trace lines...',
);

const filePathExtractor = FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher);
const filePathExtractor =
FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher);
final filePath = filePathExtractor.filePath;

expect(filePath, '/path/to/file.dart');
Expand All @@ -140,7 +166,8 @@ void minorTests({
'no file path in this stack trace\nother stack trace lines...',
);

const filePathExtractor = FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher);
const filePathExtractor =
FilePathExtractor(stackTraceFetcher: fakeStackTraceFetcher);

expect(
() => filePathExtractor.filePath,
Expand Down

0 comments on commit b179a26

Please sign in to comment.