forked from dart-lang/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dart-lang/main
Added `workspace:` and `resolution: fields` (dart-lang#1948)
- Loading branch information
Showing
5 changed files
with
88 additions
and
23 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
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
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 |
---|---|---|
|
@@ -32,31 +32,41 @@ void main() { | |
expect(value.repository, isNull); | ||
expect(value.issueTracker, isNull); | ||
expect(value.screenshots, isEmpty); | ||
expect(value.workspace, isNull); | ||
expect(value.resolution, isNull); | ||
}); | ||
|
||
test('all fields set', () async { | ||
final version = Version.parse('1.2.3'); | ||
final sdkConstraint = VersionConstraint.parse('>=2.12.0 <3.0.0'); | ||
final value = await parse({ | ||
'name': 'sample', | ||
'version': version.toString(), | ||
'publish_to': 'none', | ||
'author': '[email protected]', | ||
'environment': {'sdk': sdkConstraint.toString()}, | ||
'description': 'description', | ||
'homepage': 'homepage', | ||
'documentation': 'documentation', | ||
'repository': 'https://github.com/example/repo', | ||
'issue_tracker': 'https://github.com/example/repo/issues', | ||
'funding': [ | ||
'https://patreon.com/example', | ||
], | ||
'topics': ['widget', 'button'], | ||
'ignored_advisories': ['111', '222'], | ||
'screenshots': [ | ||
{'description': 'my screenshot', 'path': 'path/to/screenshot'}, | ||
], | ||
}); | ||
final sdkConstraint = VersionConstraint.parse('>=3.6.0 <4.0.0'); | ||
final value = await parse( | ||
{ | ||
'name': 'sample', | ||
'version': version.toString(), | ||
'publish_to': 'none', | ||
'author': '[email protected]', | ||
'environment': {'sdk': sdkConstraint.toString()}, | ||
'description': 'description', | ||
'homepage': 'homepage', | ||
'documentation': 'documentation', | ||
'repository': 'https://github.com/example/repo', | ||
'issue_tracker': 'https://github.com/example/repo/issues', | ||
'funding': [ | ||
'https://patreon.com/example', | ||
], | ||
'topics': ['widget', 'button'], | ||
'ignored_advisories': ['111', '222'], | ||
'screenshots': [ | ||
{'description': 'my screenshot', 'path': 'path/to/screenshot'}, | ||
], | ||
'workspace': [ | ||
'pkg1', | ||
'pkg2', | ||
], | ||
'resolution': 'workspace', | ||
}, | ||
skipTryPub: true, | ||
); | ||
expect(value.name, 'sample'); | ||
expect(value.version, version); | ||
expect(value.publishTo, 'none'); | ||
|
@@ -86,6 +96,10 @@ void main() { | |
expect(value.screenshots, hasLength(1)); | ||
expect(value.screenshots!.first.description, 'my screenshot'); | ||
expect(value.screenshots!.first.path, 'path/to/screenshot'); | ||
expect(value.workspace, hasLength(2)); | ||
expect(value.workspace!.first, 'pkg1'); | ||
expect(value.workspace!.last, 'pkg2'); | ||
expect(value.resolution, 'workspace'); | ||
}); | ||
|
||
test('environment values can be null', () async { | ||
|
@@ -712,4 +726,40 @@ line 1, column 1: Not a map | |
); | ||
}); | ||
}); | ||
|
||
group('workspaces', () { | ||
test('workspace key must be a list', () { | ||
expectParseThrowsContaining( | ||
{ | ||
...defaultPubspec, | ||
'workspace': 42, | ||
}, | ||
'Unsupported value for "workspace". type \'int\' is not a subtype of type \'List<dynamic>?\' in type cast', | ||
skipTryPub: true, | ||
); | ||
}); | ||
|
||
test('workspace key must be a list of strings', () { | ||
expectParseThrowsContaining( | ||
{ | ||
...defaultPubspec, | ||
'workspace': [42], | ||
}, | ||
'Unsupported value for "workspace". type \'int\' is not a subtype of type \'String\' in type cast', | ||
skipTryPub: true, | ||
); | ||
}); | ||
|
||
test('resolution key must be a string', () { | ||
expectParseThrowsContaining( | ||
{ | ||
'name': 'sample', | ||
'environment': {'sdk': '^3.6.0'}, | ||
'resolution': 42, | ||
}, | ||
'Unsupported value for "resolution". type \'int\' is not a subtype of type \'String?\' in type cast', | ||
skipTryPub: true, | ||
); | ||
}); | ||
}); | ||
} |