-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb01239
commit 9e83f6d
Showing
1 changed file
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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 { | ||
|
@@ -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") | ||
} | ||
}) | ||
} |