@@ -601,6 +601,73 @@ This is necessary because of X, Y, and Z
601
601
);
602
602
});
603
603
604
+ test (
605
+ 'fails gracefully if the version headers are not found due to using the wrong style' ,
606
+ () async {
607
+ final Directory pluginDirectory =
608
+ createFakePlugin ('plugin' , packagesDir, version: '1.0.0' );
609
+
610
+ const String changelog = '''
611
+ ## NEXT
612
+ * Some changes for a later release.
613
+ # 1.0.0
614
+ * Some other changes.
615
+ ''' ;
616
+ createFakeCHANGELOG (pluginDirectory, changelog);
617
+ gitShowResponses = < String , String > {
618
+ 'master:packages/plugin/pubspec.yaml' : 'version: 1.0.0' ,
619
+ };
620
+
621
+ Error ? commandError;
622
+ final List <String > output = await runCapturingPrint (runner, < String > [
623
+ 'version-check' ,
624
+ '--base-sha=master' ,
625
+ ], errorHandler: (Error e) {
626
+ commandError = e;
627
+ });
628
+
629
+ expect (commandError, isA <ToolExit >());
630
+ expect (
631
+ output,
632
+ containsAllInOrder (< Matcher > [
633
+ contains ('Unable to find a version in CHANGELOG.md' ),
634
+ contains ('The current version should be on a line starting with '
635
+ '"## ", either on the first non-empty line or after a "## NEXT" '
636
+ 'section.' ),
637
+ ]),
638
+ );
639
+ });
640
+
641
+ test ('fails gracefully if the version is unparseable' , () async {
642
+ final Directory pluginDirectory =
643
+ createFakePlugin ('plugin' , packagesDir, version: '1.0.0' );
644
+
645
+ const String changelog = '''
646
+ ## Alpha
647
+ * Some changes.
648
+ ''' ;
649
+ createFakeCHANGELOG (pluginDirectory, changelog);
650
+ gitShowResponses = < String , String > {
651
+ 'master:packages/plugin/pubspec.yaml' : 'version: 1.0.0' ,
652
+ };
653
+
654
+ Error ? commandError;
655
+ final List <String > output = await runCapturingPrint (runner, < String > [
656
+ 'version-check' ,
657
+ '--base-sha=master' ,
658
+ ], errorHandler: (Error e) {
659
+ commandError = e;
660
+ });
661
+
662
+ expect (commandError, isA <ToolExit >());
663
+ expect (
664
+ output,
665
+ containsAllInOrder (< Matcher > [
666
+ contains ('"Alpha" could not be parsed as a version.' ),
667
+ ]),
668
+ );
669
+ });
670
+
604
671
test ('allows valid against pub' , () async {
605
672
mockHttpResponse = < String , dynamic > {
606
673
'name' : 'some_package' ,
0 commit comments