3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
5
// ignore_for_file: deprecated_member_use_from_same_package
6
+ // ignore_for_file: lines_longer_than_80_chars
7
+
6
8
library parse_test;
7
9
8
10
import 'package:pub_semver/pub_semver.dart' ;
@@ -22,7 +24,7 @@ void main() {
22
24
expect (value.authors, isEmpty);
23
25
expect (
24
26
value.environment,
25
- {'sdk' : VersionConstraint .parse ('>=2.7 .0 <3.0.0' )},
27
+ {'sdk' : VersionConstraint .parse ('>=2.12 .0 <3.0.0' )},
26
28
);
27
29
expect (value.documentation, isNull);
28
30
expect (value.dependencies, isEmpty);
@@ -36,7 +38,7 @@ void main() {
36
38
37
39
test ('all fields set' , () {
38
40
final version = Version .parse ('1.2.3' );
39
- final sdkConstraint = VersionConstraint .parse ('>=2.0.0-dev.54 <3.0.0' );
41
+ final sdkConstraint = VersionConstraint .parse ('>=2.12.0 <3.0.0' );
40
42
final value = parse ({
41
43
'name' : 'sample' ,
42
44
'version' : version.toString (),
@@ -85,7 +87,7 @@ void main() {
85
87
{
86
88
'name' : 'sample' ,
87
89
'environment' : {
88
- 'sdk' : '>=2.7 .0 <3.0.0' ,
90
+ 'sdk' : '>=2.12 .0 <3.0.0' ,
89
91
'bob' : null ,
90
92
}
91
93
},
@@ -98,12 +100,7 @@ void main() {
98
100
99
101
group ('publish_to' , () {
100
102
for (var entry in {
101
- 42 : r'''
102
- line 3, column 16: Unsupported value for "publish_to". type 'int' is not a subtype of type 'String?' in type cast
103
- ╷
104
- 3 │ "publish_to": 42
105
- │ ^^
106
- ╵''' ,
103
+ 42 : "Unsupported value for \" publish_to\" . type 'int' is not a subtype of type 'String?'" ,
107
104
'##not a uri!' : r'''
108
105
line 3, column 16: Unsupported value for "publish_to". Must be an http or https URL.
109
106
╷
@@ -124,7 +121,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https
124
121
╵''' ,
125
122
}.entries) {
126
123
test ('cannot be `${entry .key }`' , () {
127
- expectParseThrows (
124
+ expectParseThrowsContaining (
128
125
{'name' : 'sample' , 'publish_to' : entry.key},
129
126
entry.value,
130
127
skipTryPub: true ,
@@ -241,26 +238,16 @@ line 1, column 1: Not a map
241
238
});
242
239
243
240
test ('missing name' , () {
244
- expectParseThrows (
241
+ expectParseThrowsContaining (
245
242
{},
246
- r'''
247
- line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'String' in type cast
248
- ╷
249
- 1 │ {}
250
- │ ^^
251
- ╵''' ,
243
+ "Missing key \" name\" . type 'Null' is not a subtype of type 'String'" ,
252
244
);
253
245
});
254
246
255
247
test ('null name value' , () {
256
- expectParseThrows (
248
+ expectParseThrowsContaining (
257
249
{'name' : null },
258
- r'''
259
- line 2, column 10: Unsupported value for "name". type 'Null' is not a subtype of type 'String' in type cast
260
- ╷
261
- 2 │ "name": null
262
- │ ^^^^
263
- ╵''' ,
250
+ "Unsupported value for \" name\" . type 'Null' is not a subtype of type 'String'" ,
264
251
);
265
252
});
266
253
@@ -336,73 +323,47 @@ line 4, column 10: Unsupported value for "sdk". Could not parse version "silly".
336
323
});
337
324
338
325
test ('bad repository url' , () {
339
- expectParseThrows (
326
+ expectParseThrowsContaining (
340
327
{
341
328
...defaultPubspec,
342
329
'repository' : {'x' : 'y' },
343
330
},
344
- r'''
345
- line 6, column 16: Unsupported value for "repository". type 'YamlMap' is not a subtype of type 'String' in type cast
346
- ╷
347
- 6 │ "repository": {
348
- │ ┌────────────────^
349
- 7 │ │ "x": "y"
350
- 8 │ └ }
351
- ╵''' ,
331
+ "Unsupported value for \" repository\" . type 'YamlMap' is not a subtype of type 'String'" ,
352
332
skipTryPub: true ,
353
333
);
354
334
});
355
335
356
336
test ('bad issue_tracker url' , () {
357
- expectParseThrows (
337
+ expectParseThrowsContaining (
358
338
{
359
339
'name' : 'sample' ,
360
340
'issue_tracker' : {'x' : 'y' },
361
341
},
362
- r'''
363
- line 3, column 19: Unsupported value for "issue_tracker". type 'YamlMap' is not a subtype of type 'String' in type cast
364
- ╷
365
- 3 │ "issue_tracker": {
366
- │ ┌───────────────────^
367
- 4 │ │ "x": "y"
368
- 5 │ └ }
369
- ╵''' ,
342
+ "Unsupported value for \" issue_tracker\" . type 'YamlMap' is not a subtype of type 'String'" ,
370
343
skipTryPub: true ,
371
344
);
372
345
});
373
346
});
374
347
375
348
group ('funding' , () {
376
349
test ('not a list' , () {
377
- expectParseThrows (
350
+ expectParseThrowsContaining (
378
351
{
379
352
...defaultPubspec,
380
353
'funding' : 1 ,
381
354
},
382
- r'''
383
- line 6, column 13: Unsupported value for "funding". type 'int' is not a subtype of type 'List<dynamic>?' in type cast
384
- ╷
385
- 6 │ "funding": 1
386
- │ ^
387
- ╵''' ,
355
+ "Unsupported value for \" funding\" . type 'int' is not a subtype of type 'List<dynamic>?'" ,
388
356
skipTryPub: true ,
389
357
);
390
358
});
391
359
392
360
test ('not an uri' , () {
393
- expectParseThrows (
361
+ expectParseThrowsContaining (
394
362
{
395
363
...defaultPubspec,
396
364
'funding' : [1 ],
397
365
},
398
- r'''
399
- line 6, column 13: Unsupported value for "funding". type 'int' is not a subtype of type 'String' in type cast
400
- ╷
401
- 6 │ "funding": [
402
- │ ┌─────────────^
403
- 7 │ │ 1
404
- 8 │ └ ]
405
- ╵''' ,
366
+ "Unsupported value for \" funding\" . type 'int' is not a subtype of type 'String'" ,
406
367
skipTryPub: true ,
407
368
);
408
369
});
@@ -608,14 +569,9 @@ line 1, column 1: Not a map
608
569
});
609
570
610
571
test ('name cannot be empty' , () {
611
- expectParseThrows (
572
+ expectParseThrowsContaining (
612
573
{},
613
- r'''
614
- line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'String' in type cast
615
- ╷
616
- 1 │ {}
617
- │ ^^
618
- ╵''' ,
574
+ "Missing key \" name\" . type 'Null' is not a subtype of type 'String'" ,
619
575
lenient: true ,
620
576
);
621
577
});
0 commit comments