@@ -25,6 +25,7 @@ func TestApprovalFromComments(t *testing.T) {
2525 approvers []string
2626 minimumApprovals int
2727 expectedStatus approvalStatus
28+ expectedResponder string
2829 }{
2930 {
3031 name : "single_approver_single_comment_approved" ,
@@ -36,6 +37,7 @@ func TestApprovalFromComments(t *testing.T) {
3637 },
3738 approvers : []string {login1 },
3839 expectedStatus : approvalStatusApproved ,
40+ expectedResponder : login1 ,
3941 },
4042 {
4143 name : "single_approver_single_comment_denied" ,
@@ -47,6 +49,7 @@ func TestApprovalFromComments(t *testing.T) {
4749 },
4850 approvers : []string {login1 },
4951 expectedStatus : approvalStatusDenied ,
52+ expectedResponder : login1 ,
5053 },
5154 {
5255 name : "single_approver_single_comment_pending" ,
@@ -58,6 +61,7 @@ func TestApprovalFromComments(t *testing.T) {
5861 },
5962 approvers : []string {login1 },
6063 expectedStatus : approvalStatusPending ,
64+ expectedResponder : "" ,
6165 },
6266 {
6367 name : "single_approver_multi_comment_approved" ,
@@ -73,6 +77,7 @@ func TestApprovalFromComments(t *testing.T) {
7377 },
7478 approvers : []string {login1 },
7579 expectedStatus : approvalStatusApproved ,
80+ expectedResponder : login1 ,
7681 },
7782 {
7883 name : "multi_approver_approved" ,
@@ -88,6 +93,7 @@ func TestApprovalFromComments(t *testing.T) {
8893 },
8994 approvers : []string {login1 , login2 },
9095 expectedStatus : approvalStatusApproved ,
96+ expectedResponder : login2 ,
9197 },
9298 {
9399 name : "multi_approver_mixed" ,
@@ -103,6 +109,7 @@ func TestApprovalFromComments(t *testing.T) {
103109 },
104110 approvers : []string {login1 , login2 },
105111 expectedStatus : approvalStatusPending ,
112+ expectedResponder : "" ,
106113 },
107114 {
108115 name : "multi_approver_denied" ,
@@ -118,6 +125,7 @@ func TestApprovalFromComments(t *testing.T) {
118125 },
119126 approvers : []string {login1 , login2 },
120127 expectedStatus : approvalStatusDenied ,
128+ expectedResponder : login1 ,
121129 },
122130 {
123131 name : "multi_approver_minimum_one_approval" ,
@@ -134,6 +142,7 @@ func TestApprovalFromComments(t *testing.T) {
134142 approvers : []string {login1 , login2 },
135143 expectedStatus : approvalStatusApproved ,
136144 minimumApprovals : 1 ,
145+ expectedResponder : login2 ,
137146 },
138147 {
139148 name : "multi_approver_minimum_two_approvals" ,
@@ -150,6 +159,7 @@ func TestApprovalFromComments(t *testing.T) {
150159 approvers : []string {login1 , login2 , login3 },
151160 expectedStatus : approvalStatusApproved ,
152161 minimumApprovals : 2 ,
162+ expectedResponder : login2 ,
153163 },
154164 {
155165 name : "multi_approver_approvals_less_than_minimum" ,
@@ -162,6 +172,7 @@ func TestApprovalFromComments(t *testing.T) {
162172 approvers : []string {login1 , login2 , login3 },
163173 expectedStatus : approvalStatusPending ,
164174 minimumApprovals : 2 ,
175+ expectedResponder : "" ,
165176 },
166177 {
167178 name : "single_approver_single_comment_approved_case_insensitive" ,
@@ -173,18 +184,23 @@ func TestApprovalFromComments(t *testing.T) {
173184 },
174185 approvers : []string {login1 },
175186 expectedStatus : approvalStatusApproved ,
187+ expectedResponder : login1u ,
176188 },
177189 }
178190
179191 for _ , testCase := range testCases {
180192 t .Run (testCase .name , func (t * testing.T ) {
181- actual , err := approvalFromComments (testCase .comments , testCase .approvers , testCase .minimumApprovals )
193+ actualStatus , actualResponder , err := approvalFromComments (testCase .comments , testCase .approvers , testCase .minimumApprovals )
182194 if err != nil {
183195 t .Fatalf ("error getting approval from comments: %v" , err )
184196 }
185197
186- if actual != testCase .expectedStatus {
187- t .Fatalf ("actual %s, expected %s" , actual , testCase .expectedStatus )
198+ if actualStatus != testCase .expectedStatus {
199+ t .Fatalf ("actual %s, expected %s" , actualStatus , testCase .expectedStatus )
200+ }
201+
202+ if actualResponder != testCase .expectedResponder {
203+ t .Fatalf ("actual responder %s, expected %s" , actualResponder , testCase .expectedResponder )
188204 }
189205 })
190206 }
0 commit comments