@@ -18,6 +18,7 @@ const {
1818 multipleCommitsAfterReview,
1919 moreThanThreeCommitsAfterReview,
2020 oddCommits,
21+ incorrectGitConfigCommits,
2122 simpleCommits,
2223 commitsAfterCi,
2324 mulipleCommitsAfterCi,
@@ -53,6 +54,7 @@ describe('PRChecker', () => {
5354 let checkCommitsAfterReviewStub ;
5455 let checkMergeableStateStub ;
5556 let checkPRState ;
57+ let checkGitConfigStub ;
5658
5759 before ( ( ) => {
5860 checkReviewsStub = sinon . stub ( checker , 'checkReviews' ) ;
@@ -63,6 +65,7 @@ describe('PRChecker', () => {
6365 sinon . stub ( checker , 'checkCommitsAfterReview' ) ;
6466 checkMergeableStateStub = sinon . stub ( checker , 'checkMergeableState' ) ;
6567 checkPRState = sinon . stub ( checker , 'checkPRState' ) ;
68+ checkGitConfigStub = sinon . stub ( checker , 'checkGitConfig' ) ;
6669 } ) ;
6770
6871 after ( ( ) => {
@@ -73,6 +76,7 @@ describe('PRChecker', () => {
7376 checkCommitsAfterReviewStub . restore ( ) ;
7477 checkMergeableStateStub . restore ( ) ;
7578 checkPRState . restore ( ) ;
79+ checkGitConfigStub . restore ( ) ;
7680 } ) ;
7781
7882 it ( 'should run necessary checks' , ( ) => {
@@ -85,6 +89,7 @@ describe('PRChecker', () => {
8589 assert . strictEqual ( checkCommitsAfterReviewStub . calledOnce , true ) ;
8690 assert . strictEqual ( checkMergeableStateStub . calledOnce , true ) ;
8791 assert . strictEqual ( checkPRState . calledOnce , true ) ;
92+ assert . strictEqual ( checkGitConfigStub . calledOnce , true ) ;
8893 } ) ;
8994 } ) ;
9095
@@ -590,6 +595,54 @@ describe('PRChecker', () => {
590595 } ) ;
591596 } ) ;
592597
598+ describe ( 'checkGitConfig' , ( ) => {
599+ it ( 'should log an error is user has wrong git config' , ( ) => {
600+ const cli = new TestCLI ( ) ;
601+ const expectedLogs = {
602+ error : [
603+ [ 'Author does not have correct git config!' ]
604+ ]
605+ } ;
606+
607+ const data = {
608+ pr : firstTimerPrivatePR ,
609+ reviewers : allGreenReviewers ,
610+ comments : commentsWithLGTM ,
611+ reviews : approvingReviews ,
612+ commits : incorrectGitConfigCommits ,
613+ collaborators,
614+ authorIsNew : ( ) => true
615+ } ;
616+
617+ const checker = new PRChecker ( cli , data , argv ) ;
618+ const status = checker . checkGitConfig ( ) ;
619+
620+ assert . deepStrictEqual ( status , false ) ;
621+ cli . assertCalledWith ( expectedLogs ) ;
622+ } ) ;
623+
624+ it ( 'should return the status of true if user had correct config' , ( ) => {
625+ const cli = new TestCLI ( ) ;
626+ const expectedLogs = { } ;
627+
628+ const data = {
629+ pr : firstTimerPrivatePR ,
630+ reviewers : allGreenReviewers ,
631+ comments : commentsWithLGTM ,
632+ reviews : approvingReviews ,
633+ commits : simpleCommits ,
634+ collaborators,
635+ authorIsNew : ( ) => true
636+ } ;
637+
638+ const checker = new PRChecker ( cli , data , argv ) ;
639+ const status = checker . checkGitConfig ( ) ;
640+
641+ assert ( status ) ;
642+ cli . assertCalledWith ( expectedLogs ) ;
643+ } ) ;
644+ } ) ;
645+
593646 describe ( 'checkCommitsAfterReview' , ( ) => {
594647 let cli = new TestCLI ( ) ;
595648
0 commit comments