Skip to content

Commit

Permalink
cleanup up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasRouckhout committed May 27, 2024
1 parent fb01239 commit 9e83f6d
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestInvoiceAddAndUpdate(t *testing.T) {
}

c := newTestClient()
t.Run("Invoice", func(t *testing.T) {
t.Run("InvoiceAddAndUpdate", func(t *testing.T) {
invoice, err := c.InvoiceAdd(context.Background(), &NewInvoiceRequest{
Invoice: &Invoice{
Number: "123",
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestInvoiceAddAndUpdate(t *testing.T) {
}

if err := c.InvoiceUpdate(ctx, &UpdateInvoiceRequest{
ID: cnote.Id,
ID: invoice.Id,
Title: "Some updated title",
}); err != nil {
if err != nil {
Expand All @@ -106,3 +106,45 @@ func TestInvoiceAddAndUpdate(t *testing.T) {
}
})
}

func TestInvoiceUpdateWithInvalidRequest(t *testing.T) {
if os.Getenv("TWIKEY_API_KEY") == "" {
t.Skip("No TWIKEY_API_KEY available")
}

c := newTestClient()
t.Run("InvoiceUpdateWithInvalidRequest", func(t *testing.T) {
invoice, err := c.InvoiceAdd(context.Background(), &NewInvoiceRequest{
Invoice: &Invoice{
Number: "123123",
Title: "TestInvoice 123123",
Date: "2021-01-01",
Duedate: "2021-03-01",
Remittance: "123123",
Amount: 10.00,
Customer: &Customer{
CustomerNumber: "123123",
Email: "[email protected]",
Address: "Derbystraat 43",
City: "Gent",
Zip: "9051",
Country: "BE",
Language: "nl",
},
},
Origin: "Go-Test",
})
if err != nil {
t.Error(err)
} else {
t.Log("New invoice", invoice.Id)
}

ctx := context.Background()
if err := c.InvoiceUpdate(ctx, &UpdateInvoiceRequest{
Title: "Some updated title",
}); err == nil {
t.Error("Update invoice call did not return an error even though we send no ID")
}
})
}

0 comments on commit 9e83f6d

Please sign in to comment.