add test to make sure
diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 267b871..7d5dfc4 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml
@@ -166,6 +166,8 @@ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_NUMBER: ${{ github.event.number }} PR_LABELS: ${{ steps.fetch-labels.outputs.labels }} + INPUT_LICENSE: ${{ inputs.license }} + INPUT_LICENSE_TEST_STRING: ${{ inputs.license_test_string }} run: | cd current_repo/ dart pub global run firehose:health \ @@ -185,8 +187,8 @@ --experiments ${{ inputs.experiments }} \ --health_yaml_name ${{ inputs.health_yaml_name }} \ --no-local \ - --license ${{ inputs.license }} \ - --license_test_string ${{ inputs.license_test_string }} + --license "$INPUT_LICENSE" \ + --license_test_string "$INPUT_LICENSE_TEST_STRING" - run: test -f current_repo/output/comment-${{ inputs.check }}.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment-${{ inputs.check }}.md if: ${{ '$action_state' == 1 }}
diff --git a/pkgs/firehose/test/license_test.dart b/pkgs/firehose/test/license_test.dart index fe9a58c..fa38820 100644 --- a/pkgs/firehose/test/license_test.dart +++ b/pkgs/firehose/test/license_test.dart
@@ -13,25 +13,42 @@ import 'package:test/test.dart'; void main() { - final fileWithLicense = File('test/fileWithLicense.dart'); - final fileWithoutLicense = File('test/fileWithoutLicense.dart'); - final licenseOptions = LicenseOptions(); + late File fileWithLicense; + late File fileWithoutLicense; + late Directory directory; - setUp(() async { - await fileWithLicense.writeAsString(licenseOptions.license); + setUpAll(() async { + directory = Directory.systemTemp.createTempSync('license_test'); + fileWithLicense = File(path.join(directory.path, 'fileWithLicense.dart')); + fileWithoutLicense = + File(path.join(directory.path, 'fileWithoutLicense.dart')); await fileWithoutLicense.writeAsString(''); }); - test('Check for licenses', () async { - final directory = Directory('test/'); + test('Check for license', () async { + final licenseOptions = LicenseOptions(); + await fileWithLicense.writeAsString(licenseOptions.license); + final filesWithoutLicenses = await getFilesWithoutLicenses( directory, [], licenseOptions.licenseTestString); expect(filesWithoutLicenses, [path.relative(fileWithoutLicense.path, from: directory.path)]); }); - tearDown(() async { - await fileWithLicense.delete(); - await fileWithoutLicense.delete(); + test('Check for custom license', () async { + final licenseOptions = LicenseOptions(license: ''' +// My custom license +// +// Dabadu''', licenseTestString: '// My '); + await fileWithLicense.writeAsString(licenseOptions.license); + + final filesWithoutLicenses = await getFilesWithoutLicenses( + directory, [], licenseOptions.licenseTestString); + expect(filesWithoutLicenses, + [path.relative(fileWithoutLicense.path, from: directory.path)]); + }); + + tearDownAll(() async { + await directory.delete(recursive: true); }); }