Skip to content

Commit

Permalink
test: add coverage options file locator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv-Maradiya committed Jan 23, 2025
1 parent 8d3ca0c commit c6452f7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkgs/coverage/test/config_file_locator_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'dart:io';
import 'package:coverage/src/coverage_options.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
final baseTestPath = 'test/test_file_locator';
late Directory testDirectory;

test('options file exists', () {
testDirectory = Directory('$baseTestPath/pkg1/lib/src');
var filePath =
CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory);
expect(path.normalize('$baseTestPath/pkg1/coverage_options.yaml'),
path.normalize(filePath!));

testDirectory = Directory('$baseTestPath/pkg1/lib');
filePath =
CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory);
expect(path.normalize('$baseTestPath/pkg1/coverage_options.yaml'),
path.normalize(filePath!));
});

test('options file missing', () {
testDirectory = Directory('$baseTestPath/pkg2/lib/src');
var filePath =
CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory);
expect(filePath, isNull);

testDirectory = Directory('$baseTestPath/pkg2/lib');
filePath =
CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory);
expect(filePath, isNull);
});

test('no pubspec found', () {
var filePath = CoverageOptionsProvider.findOptionsFilePath(
directory: Directory.systemTemp);
expect(filePath, isNull);

filePath = CoverageOptionsProvider.findOptionsFilePath(
directory: Directory.systemTemp);
expect(filePath, isNull);
});
}
Empty file.
Empty file.
Empty file.

0 comments on commit c6452f7

Please sign in to comment.