Skip to content

Commit

Permalink
[DE-801] Fix invoice events test
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-nedza committed Jun 5, 2024
1 parent 723121c commit a3e9824
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
34 changes: 22 additions & 12 deletions test/invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
},
{
Expand Down

0 comments on commit a3e9824

Please sign in to comment.