|
| 1 | +import 'dart:io'; |
| 2 | +import 'package:coverage/src/coverage_options.dart'; |
| 3 | +import 'package:path/path.dart' as path; |
| 4 | +import 'package:test/test.dart'; |
| 5 | + |
| 6 | +void main() { |
| 7 | + final baseTestPath = 'test/test_file_locator'; |
| 8 | + late Directory testDirectory; |
| 9 | + |
| 10 | + test('options file exists', () { |
| 11 | + testDirectory = Directory('$baseTestPath/pkg1/lib/src'); |
| 12 | + var filePath = |
| 13 | + CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory); |
| 14 | + expect(path.normalize('$baseTestPath/pkg1/coverage_options.yaml'), |
| 15 | + path.normalize(filePath!)); |
| 16 | + |
| 17 | + testDirectory = Directory('$baseTestPath/pkg1/lib'); |
| 18 | + filePath = |
| 19 | + CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory); |
| 20 | + expect(path.normalize('$baseTestPath/pkg1/coverage_options.yaml'), |
| 21 | + path.normalize(filePath!)); |
| 22 | + }); |
| 23 | + |
| 24 | + test('options file missing', () { |
| 25 | + testDirectory = Directory('$baseTestPath/pkg2/lib/src'); |
| 26 | + var filePath = |
| 27 | + CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory); |
| 28 | + expect(filePath, isNull); |
| 29 | + |
| 30 | + testDirectory = Directory('$baseTestPath/pkg2/lib'); |
| 31 | + filePath = |
| 32 | + CoverageOptionsProvider.findOptionsFilePath(directory: testDirectory); |
| 33 | + expect(filePath, isNull); |
| 34 | + }); |
| 35 | + |
| 36 | + test('no pubspec found', () { |
| 37 | + var filePath = CoverageOptionsProvider.findOptionsFilePath( |
| 38 | + directory: Directory.systemTemp); |
| 39 | + expect(filePath, isNull); |
| 40 | + |
| 41 | + filePath = CoverageOptionsProvider.findOptionsFilePath( |
| 42 | + directory: Directory.systemTemp); |
| 43 | + expect(filePath, isNull); |
| 44 | + }); |
| 45 | +} |
0 commit comments