Repository navigation
fix: quieten the update check and say how to recover a newer manifest #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,77 @@ | ||
| import 'package:mason_logger/mason_logger.dart'; | ||
| import 'package:mocktail/mocktail.dart'; | ||
| import 'package:pub_updater/pub_updater.dart'; | ||
| import 'package:vgv_ai_cli/src/command_runner.dart'; | ||
| import 'package:vgv_ai_cli/src/commands/commands.dart'; | ||
| import 'package:vgv_ai_cli/src/version.dart'; | ||
|
|
||
| class _MockLogger extends Mock implements Logger; | ||
|
|
||
| class _MockProgress extends Mock implements Progress; | ||
|
|
||
| class _MockPubUpdater extends Mock implements PubUpdater; | ||
|
|
||
| /// {@template test_runner} | ||
| /// The mocked collaborators a command test runs against, stubbed the way | ||
| /// every one of them needs: the CLI is already up to date, and the progress | ||
| /// [logger] hands out records its messages in [progressLogs]. | ||
| /// | ||
| /// Tests that need another answer re-stub [logger], [progress] or | ||
| /// [pubUpdater] themselves. | ||
| /// {@endtemplate} | ||
| class TestRunner() { | ||
| /// {@macro test_runner} | ||
| this { | ||
| when(() => logger.progress(any())).thenReturn(progress); | ||
| when(() => progress.complete(any())).thenAnswer((invocation) { | ||
| final message = invocation.positionalArguments.first as String?; | ||
| if (message != null) progressLogs.add(message); | ||
| }); | ||
| when(() => pubUpdater.getLatestVersion(any())) | ||
| .thenAnswer((_) async => packageVersion); | ||
| when( | ||
| () => pubUpdater.isUpToDate( | ||
| packageName: any(named: 'packageName'), | ||
| currentVersion: any(named: 'currentVersion'), | ||
| ), | ||
| ).thenAnswer((_) async => true); | ||
| } | ||
|
|
||
| /// The logger the runner and its commands write to. | ||
| final Logger logger = _MockLogger(); | ||
|
|
||
| /// The progress [logger] returns. | ||
| final Progress progress = _MockProgress(); | ||
|
|
||
| /// The updater the runner checks the latest version with. | ||
| final PubUpdater pubUpdater = _MockPubUpdater(); | ||
|
|
||
| /// What [progress] was completed with, in order. | ||
| final List<String> progressLogs = <String>[]; | ||
|
|
||
| /// A runner carrying [logger] and [pubUpdater], with the given commands | ||
| /// replacing the ones that would otherwise reach the real home directory. | ||
| VgvAiCliCommandRunner build({ | ||
| InstallCommand? installCommand, | ||
| DoctorCommand? doctorCommand, | ||
| UninstallCommand? uninstallCommand, | ||
| }) => VgvAiCliCommandRunner( | ||
| logger: logger, | ||
| pubUpdater: pubUpdater, | ||
| installCommand: installCommand, | ||
| doctorCommand: doctorCommand, | ||
| uninstallCommand: uninstallCommand, | ||
| ); | ||
|
|
||
| /// Runs [args] through a runner from [build]. | ||
| Future<int> run( | ||
| List<String> args, { | ||
| InstallCommand? installCommand, | ||
| DoctorCommand? doctorCommand, | ||
| UninstallCommand? uninstallCommand, | ||
| }) => build( | ||
| installCommand: installCommand, | ||
| doctorCommand: doctorCommand, | ||
| uninstallCommand: uninstallCommand, | ||
| ).run(args); | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.