@@ -56,6 +56,7 @@ void main() {
56
56
bool includeHomepage = false ,
57
57
bool includeIssueTracker = true ,
58
58
bool publishable = true ,
59
+ String ? description,
59
60
}) {
60
61
final String repositoryPath = repositoryPackagesDirRelativePath ?? name;
61
62
final String repoLink = 'https://github.com/flutter/'
@@ -64,8 +65,11 @@ void main() {
64
65
final String issueTrackerLink =
65
66
'https://github.com/flutter/flutter/issues?'
66
67
'q=is%3Aissue+is%3Aopen+label%3A%22p%3A+$name %22' ;
68
+ description ?? = 'A test package for validating that the pubspec.yaml '
69
+ 'follows repo best practices.' ;
67
70
return '''
68
71
name: $name
72
+ description: $description
69
73
${includeRepository ? 'repository: $repoLink ' : '' }
70
74
${includeHomepage ? 'homepage: $repoLink ' : '' }
71
75
${includeIssueTracker ? 'issue_tracker: $issueTrackerLink ' : '' }
@@ -327,6 +331,95 @@ ${devDependenciesSection()}
327
331
);
328
332
});
329
333
334
+ test ('fails when description is too short' , () async {
335
+ final Directory pluginDirectory =
336
+ createFakePlugin ('a_plugin' , packagesDir.childDirectory ('a_plugin' ));
337
+
338
+ pluginDirectory.childFile ('pubspec.yaml' ).writeAsStringSync ('''
339
+ ${headerSection ('plugin' , isPlugin : true , description : 'Too short' )}
340
+ ${environmentSection ()}
341
+ ${flutterSection (isPlugin : true )}
342
+ ${dependenciesSection ()}
343
+ ${devDependenciesSection ()}
344
+ ''' );
345
+
346
+ Error ? commandError;
347
+ final List <String > output = await runCapturingPrint (
348
+ runner, < String > ['pubspec-check' ], errorHandler: (Error e) {
349
+ commandError = e;
350
+ });
351
+
352
+ expect (commandError, isA <ToolExit >());
353
+ expect (
354
+ output,
355
+ containsAllInOrder (< Matcher > [
356
+ contains ('"description" is too short. pub.dev recommends package '
357
+ 'descriptions of 60-180 characters.' ),
358
+ ]),
359
+ );
360
+ });
361
+
362
+ test (
363
+ 'allows short descriptions for non-app-facing parts of federated plugins' ,
364
+ () async {
365
+ final Directory pluginDirectory = createFakePlugin ('plugin' , packagesDir);
366
+
367
+ pluginDirectory.childFile ('pubspec.yaml' ).writeAsStringSync ('''
368
+ ${headerSection ('plugin' , isPlugin : true , description : 'Too short' )}
369
+ ${environmentSection ()}
370
+ ${flutterSection (isPlugin : true )}
371
+ ${dependenciesSection ()}
372
+ ${devDependenciesSection ()}
373
+ ''' );
374
+
375
+ Error ? commandError;
376
+ final List <String > output = await runCapturingPrint (
377
+ runner, < String > ['pubspec-check' ], errorHandler: (Error e) {
378
+ commandError = e;
379
+ });
380
+
381
+ expect (commandError, isA <ToolExit >());
382
+ expect (
383
+ output,
384
+ containsAllInOrder (< Matcher > [
385
+ contains ('"description" is too short. pub.dev recommends package '
386
+ 'descriptions of 60-180 characters.' ),
387
+ ]),
388
+ );
389
+ });
390
+
391
+ test ('fails when description is too long' , () async {
392
+ final Directory pluginDirectory = createFakePlugin ('plugin' , packagesDir);
393
+
394
+ const String description = 'This description is too long. It just goes '
395
+ 'on and on and on and on and on. pub.dev will down-score it because '
396
+ 'there is just too much here. Someone shoul really cut this down to just '
397
+ 'the core description so that search results are more useful and the '
398
+ 'package does not lose pub points.' ;
399
+ pluginDirectory.childFile ('pubspec.yaml' ).writeAsStringSync ('''
400
+ ${headerSection ('plugin' , isPlugin : true , description : description )}
401
+ ${environmentSection ()}
402
+ ${flutterSection (isPlugin : true )}
403
+ ${dependenciesSection ()}
404
+ ${devDependenciesSection ()}
405
+ ''' );
406
+
407
+ Error ? commandError;
408
+ final List <String > output = await runCapturingPrint (
409
+ runner, < String > ['pubspec-check' ], errorHandler: (Error e) {
410
+ commandError = e;
411
+ });
412
+
413
+ expect (commandError, isA <ToolExit >());
414
+ expect (
415
+ output,
416
+ containsAllInOrder (< Matcher > [
417
+ contains ('"description" is too long. pub.dev recommends package '
418
+ 'descriptions of 60-180 characters.' ),
419
+ ]),
420
+ );
421
+ });
422
+
330
423
test ('fails when environment section is out of order' , () async {
331
424
final Directory pluginDirectory = createFakePlugin ('plugin' , packagesDir);
332
425
0 commit comments