Skip to content

Commit

Permalink
Add a simple test for InvoiceUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasRouckhout committed May 27, 2024
1 parent 612c739 commit e07e561
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ func (c *Client) InvoiceUpdate(ctx context.Context, request *UpdateInvoiceReques
return err
}

if request.ID == "" {
return errors.New("missing invoice id")
}

body, err := json.Marshal(request)
if err != nil {
return err
Expand Down
14 changes: 13 additions & 1 deletion invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func TestInvoiceAdd(t *testing.T) {
t.Log("New invoice", invoice.Id)
}

cnote, err := c.InvoiceAdd(context.Background(), &NewInvoiceRequest{
ctx := context.Background()
cnote, err := c.InvoiceAdd(ctx, &NewInvoiceRequest{
Invoice: &Invoice{
Number: "124",
RelatedInvoice: "123",
Expand All @@ -92,5 +93,16 @@ func TestInvoiceAdd(t *testing.T) {
} else {
t.Log("New CreditNote", cnote.Id)
}

if err := c.InvoiceUpdate(ctx, &UpdateInvoiceRequest{
ID: cnote.Id,
Title: "Some updated title",
}); err != nil {
if err != nil {
t.Error(err)
} else {
t.Log("Updated invoice", cnote.Id)
}
}
})
}

0 comments on commit e07e561

Please sign in to comment.