Skip to content

Commit 44b5e60

Browse files
committed
test(e2e): send empty void grant request
1 parent 3c2bd1d commit 44b5e60

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

e2e/customer_credits_v3_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func TestV3VoidCreditGrant(t *testing.T) {
187187

188188
// when:
189189
// - the first grant is voided
190-
status, voided, problem := c.VoidCreditGrant(customerID, grant.Id, nil)
190+
status, voided, problem := c.VoidCreditGrant(customerID, grant.Id, apiv3.VoidCreditGrantRequest{})
191191
require.Equal(t, http.StatusOK, status, "problem: %+v", problem)
192192
require.NotNil(t, voided)
193193

@@ -212,7 +212,7 @@ func TestV3VoidCreditGrant(t *testing.T) {
212212
})
213213

214214
t.Run("retrying the void is an idempotent success", func(t *testing.T) {
215-
status, again, problem := c.VoidCreditGrant(customerID, grant.Id, nil)
215+
status, again, problem := c.VoidCreditGrant(customerID, grant.Id, apiv3.VoidCreditGrantRequest{})
216216
require.Equal(t, http.StatusOK, status, "problem: %+v", problem)
217217
require.NotNil(t, again)
218218
require.Equal(t, apiv3.BillingCreditGrantStatusVoided, again.Status)
@@ -265,7 +265,7 @@ func TestV3VoidCreditGrant(t *testing.T) {
265265
})
266266

267267
t.Run("voiding an unknown grant is a 404", func(t *testing.T) {
268-
status, _, problem := c.VoidCreditGrant(customerID, ulid.Make().String(), nil)
268+
status, _, problem := c.VoidCreditGrant(customerID, ulid.Make().String(), apiv3.VoidCreditGrantRequest{})
269269
require.Equal(t, http.StatusNotFound, status, "problem: %+v", problem)
270270
})
271271
}
@@ -293,7 +293,7 @@ func TestV3VoidCreditGrantPaymentAdjustmentNone(t *testing.T) {
293293

294294
paymentAdjustment := apiv3.BillingCreditGrantVoidPaymentAdjustmentNone
295295

296-
status, voided, problem := c.VoidCreditGrant(customer.Id, grant.Id, &apiv3.VoidCreditGrantRequest{
296+
status, voided, problem := c.VoidCreditGrant(customer.Id, grant.Id, apiv3.VoidCreditGrantRequest{
297297
PaymentAdjustment: &paymentAdjustment,
298298
})
299299
require.Equal(t, http.StatusOK, status, "problem: %+v", problem)

e2e/v3helpers_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,8 @@ func (c *v3Client) ListCreditGrantsByStatus(customerID string, grantStatus apiv3
476476
}
477477

478478
// VoidCreditGrant voids a credit grant, forfeiting the remaining unused balance.
479-
func (c *v3Client) VoidCreditGrant(customerID, creditGrantID string, body *apiv3.VoidCreditGrantRequest) (int, *apiv3.BillingCreditGrant, *v3Problem) {
480-
var requestBody any
481-
if body != nil {
482-
requestBody = body
483-
}
484-
485-
status, raw, problem := c.do(http.MethodPost, "/customers/"+customerID+"/credits/grants/"+creditGrantID+"/void", requestBody)
479+
func (c *v3Client) VoidCreditGrant(customerID, creditGrantID string, body apiv3.VoidCreditGrantRequest) (int, *apiv3.BillingCreditGrant, *v3Problem) {
480+
status, raw, problem := c.do(http.MethodPost, "/customers/"+customerID+"/credits/grants/"+creditGrantID+"/void", body)
486481
return decodeTyped[apiv3.BillingCreditGrant](c, status, raw, problem, http.StatusOK)
487482
}
488483

0 commit comments

Comments
 (0)