-
Notifications
You must be signed in to change notification settings - Fork 6
/
line_items_test.go
59 lines (48 loc) · 984 Bytes
/
line_items_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package invoiced
import (
"encoding/json"
"testing"
)
func TestUnMarshalLineItemObject(t *testing.T) {
s := `{
"id": 8,
"catalog_item": "delivery",
"type": "service",
"name": "Delivery",
"description": "",
"quantity": 1,
"unit_cost": 10,
"amount": 10,
"discountable": true,
"discounts": [],
"taxable": true,
"taxes": [],
"metadata": {}
}`
so := new(LineItem)
err := json.Unmarshal([]byte(s), so)
if err != nil {
t.Fatal(err)
}
if so.Id != 8 {
t.Fatal("ItemClient 1 has incorrect id")
}
if so.Type != "service" {
t.Fatal("ItemClient 1 has incorrect type")
}
if so.Name != "Delivery" {
t.Fatal("ItemClient 0 has incorrect name")
}
if so.Quantity != 1.0 {
t.Fatal("ItemClient 1 has incorrect quantity")
}
if so.UnitCost != 10 {
t.Fatal("ItemClient 1 has incorrect unit cost")
}
if so.Amount != 10 {
t.Fatal("ItemClient 1 has incorrect amount")
}
if !so.Taxable {
t.Fatal("ItemClient 1 has incorrect taxable")
}
}