@@ -2,6 +2,7 @@ package e2e
22
33import (
44 "net/http"
5+ "slices"
56 "testing"
67 "time"
78
@@ -198,12 +199,12 @@ func TestV3GetBillingInvoice(t *testing.T) {
198199 require .Equal (c , http .StatusOK , listResp .StatusCode (), "list invoices: %s" , string (listResp .Body ))
199200 require .NotNil (c , listResp .JSON200 )
200201
201- inv , foundStandard := lo . Find (listResp .JSON200 .Items , func (inv api.Invoice ) bool {
202+ standardInvoiceIdx := slices . IndexFunc (listResp .JSON200 .Items , func (inv api.Invoice ) bool {
202203 return inv .Status != api .InvoiceStatusGathering
203204 })
204- require .True (c , foundStandard , "expected charges to advance a pending line into a standard invoice" )
205+ require .NotEqual (c , - 1 , standardInvoiceIdx , "expected charges to advance a pending line into a standard invoice" )
205206
206- invoiceID = inv .Id
207+ invoiceID = listResp . JSON200 . Items [ standardInvoiceIdx ] .Id
207208 }, time .Minute , time .Second )
208209 require .NotEmpty (t , invoiceID )
209210 })
@@ -220,10 +221,10 @@ func TestV3GetBillingInvoice(t *testing.T) {
220221 require .NotNil (t , listResp .JSON200 )
221222 require .NotEmpty (t , listResp .JSON200 .Items , "expected at least one invoice for customer %s (key: %s)" , customerID , customerKey )
222223
223- _ , foundStandard := lo . Find (listResp .JSON200 .Items , func (inv api.Invoice ) bool {
224+ standardInvoiceIdx := slices . IndexFunc (listResp .JSON200 .Items , func (inv api.Invoice ) bool {
224225 return inv .Status != api .InvoiceStatusGathering
225226 })
226- require .True (t , foundStandard , "expected at least one non-gathering invoice in the list" )
227+ require .NotEqual (t , - 1 , standardInvoiceIdx , "expected at least one non-gathering invoice in the list" )
227228 })
228229
229230 t .Run ("Should return the invoice via v3 GET" , func (t * testing.T ) {
0 commit comments