-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into alestiago/always-local-license-check
- Loading branch information
Showing
6 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
e2e/test/commands/packages/check/licenses/licenses_allowed_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:mason/mason.dart'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../../../helpers/helpers.dart'; | ||
|
||
/// Objectives: | ||
/// | ||
/// * Generate a new Dart project using (`dart create`) | ||
/// * Add dependencies to `pubspec.yaml` with an MIT license | ||
/// * Run `very_good packages check licenses --allowed="MIT"` and expect success | ||
void main() { | ||
test( | ||
'packages check licenses --allowed="MIT"', | ||
timeout: const Timeout(Duration(minutes: 2)), | ||
withRunner((commandRunner, logger, updater, logs) async { | ||
final tempDirectory = Directory.systemTemp.createTempSync(); | ||
addTearDown(() => tempDirectory.deleteSync(recursive: true)); | ||
|
||
const projectName = 'my_dart_project'; | ||
await expectSuccessfulProcessResult( | ||
'dart', | ||
['create', 'my_dart_project', '--no-pub'], | ||
workingDirectory: tempDirectory.path, | ||
); | ||
final projectPath = path.join(tempDirectory.path, projectName); | ||
await expectSuccessfulProcessResult( | ||
'dart', | ||
['pub', 'add', 'formz'], | ||
workingDirectory: projectPath, | ||
); | ||
await expectSuccessfulProcessResult( | ||
'dart', | ||
['pub', 'get'], | ||
workingDirectory: projectPath, | ||
); | ||
|
||
final relativeProjectPath = path.relative( | ||
projectPath, | ||
from: Directory.current.path, | ||
); | ||
final resultAllowed = await commandRunner.run( | ||
[ | ||
'packages', | ||
'check', | ||
'licenses', | ||
'--allowed=MIT', | ||
relativeProjectPath, | ||
], | ||
); | ||
expect( | ||
resultAllowed, | ||
equals(ExitCode.success.code), | ||
reason: 'Should succeed when allowed licenses are used', | ||
); | ||
}), | ||
); | ||
} |
62 changes: 62 additions & 0 deletions
62
e2e/test/commands/packages/check/licenses/licenses_forbidden_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:mason/mason.dart'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../../../helpers/helpers.dart'; | ||
|
||
/// Objectives: | ||
/// | ||
/// * Generate a new Dart project using (`dart create`) | ||
/// * Add dependencies to `pubspec.yaml` with an MIT license | ||
/// * Run `very_good packages check licenses --forbidden="MIT"` and expect | ||
/// failure | ||
void main() { | ||
test( | ||
'packages check licenses --forbidden="MIT"', | ||
timeout: const Timeout(Duration(minutes: 2)), | ||
withRunner((commandRunner, logger, updater, logs) async { | ||
final tempDirectory = Directory.systemTemp.createTempSync(); | ||
addTearDown(() => tempDirectory.deleteSync(recursive: true)); | ||
|
||
const projectName = 'my_dart_project'; | ||
await expectSuccessfulProcessResult( | ||
'dart', | ||
['create', 'my_dart_project', '--no-pub'], | ||
workingDirectory: tempDirectory.path, | ||
); | ||
final projectPath = path.join(tempDirectory.path, projectName); | ||
await expectSuccessfulProcessResult( | ||
'dart', | ||
['pub', 'add', 'formz'], | ||
workingDirectory: projectPath, | ||
); | ||
await expectSuccessfulProcessResult( | ||
'dart', | ||
['pub', 'get'], | ||
workingDirectory: projectPath, | ||
); | ||
|
||
final relativeProjectPath = path.relative( | ||
projectPath, | ||
from: Directory.current.path, | ||
); | ||
|
||
final resultForbidden = await commandRunner.run( | ||
[ | ||
'packages', | ||
'check', | ||
'licenses', | ||
'--forbidden=MIT', | ||
relativeProjectPath, | ||
], | ||
); | ||
expect( | ||
resultForbidden, | ||
equals(ExitCode.config.code), | ||
reason: 'Should fail when forbidden licenses are used', | ||
); | ||
}), | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters