Skip to content

Commit

Permalink
Add info project validator status (flutter#109169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasguerrero authored and camsim99 committed Aug 10, 2022
1 parent ad1c4c2 commit 1c365d0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
Expand Up @@ -76,6 +76,7 @@ class ValidateProject {
case StatusProjectValidator.error:
icon = '[✗]';
break;
case StatusProjectValidator.info:
case StatusProjectValidator.success:
icon = '[✓]';
break;
Expand Down
25 changes: 11 additions & 14 deletions packages/flutter_tools/lib/src/project_validator.dart
Expand Up @@ -153,25 +153,22 @@ class PubDependenciesProjectValidator extends ProjectValidator {
}
}

final String value;
if (dependencies.isNotEmpty) {
final String verb = dependencies.length == 1 ? 'is' : 'are';
result.add(
ProjectValidatorResult(
name: name,
value: '${dependencies.join(', ')} $verb not hosted',
status: StatusProjectValidator.warning,
)
);
value = '${dependencies.join(', ')} $verb not hosted';
} else {
result.add(
const ProjectValidatorResult(
name: name,
value: 'All pub dependencies are hosted on https://pub.dartlang.org',
status: StatusProjectValidator.success,
)
);
value = 'All pub dependencies are hosted on https://pub.dartlang.org';
}

result.add(
ProjectValidatorResult(
name: name,
value: value,
status: StatusProjectValidator.info,
)
);

return result;
}

Expand Down
Expand Up @@ -7,6 +7,7 @@ enum StatusProjectValidator {
warning,
success,
crash,
info,
}

class ProjectValidatorResult {
Expand Down
Expand Up @@ -35,7 +35,7 @@ void main() {
const String expected = 'All pub dependencies are hosted on https://pub.dartlang.org';
expect(result.length, 1);
expect(result[0].value, expected);
expect(result[0].status, StatusProjectValidator.success);
expect(result[0].status, StatusProjectValidator.info);
});

testWithoutContext('error when command dart pub deps fails', () async {
Expand All @@ -56,7 +56,7 @@ void main() {
expect(result[0].status, StatusProjectValidator.error);
});

testWithoutContext('warning on dependencies not hosted', () async {
testWithoutContext('info on dependencies not hosted', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <String>['dart', 'pub', 'deps', '--json'],
Expand All @@ -71,7 +71,7 @@ void main() {
const String expected = 'dep1, dep2 are not hosted';
expect(result.length, 1);
expect(result[0].value, expected);
expect(result[0].status, StatusProjectValidator.warning);
expect(result[0].status, StatusProjectValidator.info);
});
});
}

0 comments on commit 1c365d0

Please sign in to comment.