@@ -32,31 +32,41 @@ void main() {
32
32
expect (value.repository, isNull);
33
33
expect (value.issueTracker, isNull);
34
34
expect (value.screenshots, isEmpty);
35
+ expect (value.workspace, isNull);
36
+ expect (value.resolution, isNull);
35
37
});
36
38
37
39
test ('all fields set' , () async {
38
40
final version = Version .parse ('1.2.3' );
39
- final sdkConstraint = VersionConstraint .parse ('>=2.12.0 <3.0.0' );
40
- final value = await parse ({
41
- 'name' : 'sample' ,
42
- 'version' : version.toString (),
43
- 'publish_to' : 'none' ,
44
- 'author' : 'name@example.com' ,
45
- 'environment' : {'sdk' : sdkConstraint.toString ()},
46
- 'description' : 'description' ,
47
- 'homepage' : 'homepage' ,
48
- 'documentation' : 'documentation' ,
49
- 'repository' : 'https://github.com/example/repo' ,
50
- 'issue_tracker' : 'https://github.com/example/repo/issues' ,
51
- 'funding' : [
52
- 'https://patreon.com/example' ,
53
- ],
54
- 'topics' : ['widget' , 'button' ],
55
- 'ignored_advisories' : ['111' , '222' ],
56
- 'screenshots' : [
57
- {'description' : 'my screenshot' , 'path' : 'path/to/screenshot' },
58
- ],
59
- });
41
+ final sdkConstraint = VersionConstraint .parse ('>=3.6.0 <4.0.0' );
42
+ final value = await parse (
43
+ {
44
+ 'name' : 'sample' ,
45
+ 'version' : version.toString (),
46
+ 'publish_to' : 'none' ,
47
+ 'author' : 'name@example.com' ,
48
+ 'environment' : {'sdk' : sdkConstraint.toString ()},
49
+ 'description' : 'description' ,
50
+ 'homepage' : 'homepage' ,
51
+ 'documentation' : 'documentation' ,
52
+ 'repository' : 'https://github.com/example/repo' ,
53
+ 'issue_tracker' : 'https://github.com/example/repo/issues' ,
54
+ 'funding' : [
55
+ 'https://patreon.com/example' ,
56
+ ],
57
+ 'topics' : ['widget' , 'button' ],
58
+ 'ignored_advisories' : ['111' , '222' ],
59
+ 'screenshots' : [
60
+ {'description' : 'my screenshot' , 'path' : 'path/to/screenshot' },
61
+ ],
62
+ 'workspace' : [
63
+ 'pkg1' ,
64
+ 'pkg2' ,
65
+ ],
66
+ 'resolution' : 'workspace' ,
67
+ },
68
+ skipTryPub: true ,
69
+ );
60
70
expect (value.name, 'sample' );
61
71
expect (value.version, version);
62
72
expect (value.publishTo, 'none' );
@@ -86,6 +96,10 @@ void main() {
86
96
expect (value.screenshots, hasLength (1 ));
87
97
expect (value.screenshots! .first.description, 'my screenshot' );
88
98
expect (value.screenshots! .first.path, 'path/to/screenshot' );
99
+ expect (value.workspace, hasLength (2 ));
100
+ expect (value.workspace! .first, 'pkg1' );
101
+ expect (value.workspace! .last, 'pkg2' );
102
+ expect (value.resolution, 'workspace' );
89
103
});
90
104
91
105
test ('environment values can be null' , () async {
@@ -712,4 +726,40 @@ line 1, column 1: Not a map
712
726
);
713
727
});
714
728
});
729
+
730
+ group ('workspaces' , () {
731
+ test ('workspace key must be a list' , () {
732
+ expectParseThrowsContaining (
733
+ {
734
+ ...defaultPubspec,
735
+ 'workspace' : 42 ,
736
+ },
737
+ 'Unsupported value for "workspace". type \' int\' is not a subtype of type \' List<dynamic>?\' in type cast' ,
738
+ skipTryPub: true ,
739
+ );
740
+ });
741
+
742
+ test ('workspace key must be a list of strings' , () {
743
+ expectParseThrowsContaining (
744
+ {
745
+ ...defaultPubspec,
746
+ 'workspace' : [42 ],
747
+ },
748
+ 'Unsupported value for "workspace". type \' int\' is not a subtype of type \' String\' in type cast' ,
749
+ skipTryPub: true ,
750
+ );
751
+ });
752
+
753
+ test ('resolution key must be a string' , () {
754
+ expectParseThrowsContaining (
755
+ {
756
+ 'name' : 'sample' ,
757
+ 'environment' : {'sdk' : '^3.6.0' },
758
+ 'resolution' : 42 ,
759
+ },
760
+ 'Unsupported value for "resolution". type \' int\' is not a subtype of type \' String?\' in type cast' ,
761
+ skipTryPub: true ,
762
+ );
763
+ });
764
+ });
715
765
}
0 commit comments