Handle null values during yaml metadata parsing validation (#104022)

This commit is contained in:
Jenn Magder
2022-05-17 18:32:09 -07:00
committed by GitHub
parent b8b3b09af8
commit 52ddc9d174
2 changed files with 28 additions and 19 deletions

View File

@@ -50,6 +50,21 @@ void main() {
expect(logger.traceText, contains('.metadata file at .metadata was empty or malformed.'));
});
testWithoutContext('projectType is populated when version is null', () {
metadataFile
..createSync()
..writeAsStringSync('''
version:
project_type: plugin
''');
final FlutterProjectMetadata projectMetadata = FlutterProjectMetadata(metadataFile, logger);
expect(projectMetadata.projectType, FlutterProjectType.plugin);
expect(projectMetadata.versionChannel, isNull);
expect(projectMetadata.versionRevision, isNull);
expect(logger.traceText, contains('The value of key `version` in .metadata was expected to be YamlMap but was Null'));
});
testWithoutContext('projectType is populated when version is malformed', () {
metadataFile
..createSync()