diff --git a/go.sum b/go.sum index 2320a323..60a9f4f2 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -github.com/apimatic/go-core-runtime v0.0.20 h1:orjqhRC43F1xDRGOYbJsosTbja3UzE60DLvloHsG9xc= -github.com/apimatic/go-core-runtime v0.0.20/go.mod h1:kyqGg2v3OTV7o2fXHgbHLZPMinqZvIqw1JwdEd64OzM= +github.com/apimatic/go-core-runtime v0.0.21 h1:05q2QqxfCxY8ejQQjJYs78DFjFvOeSnMl3EZNRuw3bc= +github.com/apimatic/go-core-runtime v0.0.21/go.mod h1:kyqGg2v3OTV7o2fXHgbHLZPMinqZvIqw1JwdEd64OzM= diff --git a/test/invoice_test.go b/test/invoice_test.go index a27567c4..12df7107 100644 --- a/test/invoice_test.go +++ b/test/invoice_test.go @@ -91,18 +91,28 @@ func (s *InvoiceSuite) TestInvoice() { s.Equal(models.InvoiceStatus_VOIDED, *void.Data.Status) // sometimes some events are missing - time.Sleep(500 * time.Millisecond) - - events, err := s.client.InvoicesController().ListInvoiceEvents( - ctx, - advancedbilling.ListInvoiceEventsInput{ - InvoiceUid: resp.Data.Invoice.Uid, // cant pass event types here. Server throws 500 - }, - ) - - s.NoError(err) - s.Equal(http.StatusOK, events.Response.StatusCode) - s.Greater(len(events.Data.Events), 0) + time.Sleep(2500 * time.Millisecond) + + events, err := s.client.InvoicesController().ListInvoiceEvents( + ctx, + advancedbilling.ListInvoiceEventsInput{ + InvoiceUid: resp.Data.Invoice.Uid, // cant pass event types here. Server throws 500 + }, + ) + + s.NoError(err) + s.Equal(http.StatusOK, events.Response.StatusCode) + s.Equal(len(events.Data.Events), 2) + + event1, ok := events.Data.Events[0].AsIssueInvoiceEvent() + s.True(ok) + s.Equal(event1.EventType, models.InvoiceEventType_ISSUEINVOICE) + s.Equal(event1.EventData.TotalAmount, "900.0") + + event2, ok := events.Data.Events[1].AsVoidInvoiceEvent() + s.True(ok) + s.Equal(event2.EventType, models.InvoiceEventType_VOIDINVOICE) + s.Equal(event2.EventData.Reason, "Duplicate invoice") }, }, {