forked from go-packages/paypal
Item.Quantity is string now
This commit is contained in:
parent
da5fe595b3
commit
1af34f3631
2
types.go
2
types.go
|
@ -147,7 +147,7 @@ type (
|
||||||
|
|
||||||
// Item struct
|
// Item struct
|
||||||
Item struct {
|
Item struct {
|
||||||
Quantity int `json:"quantity"`
|
Quantity string `json:"quantity"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Price string `json:"price"`
|
Price string `json:"price"`
|
||||||
Currency string `json:"currency"`
|
Currency string `json:"currency"`
|
||||||
|
|
|
@ -30,3 +30,25 @@ func TestTypeUserInfo(t *testing.T) {
|
||||||
t.Errorf("UserInfo decoded result is incorrect, Given: %v", u)
|
t.Errorf("UserInfo decoded result is incorrect, Given: %v", u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTypeItem(t *testing.T) {
|
||||||
|
response := `{
|
||||||
|
"name":"Item",
|
||||||
|
"price":"22.99",
|
||||||
|
"currency":"GBP",
|
||||||
|
"quantity":"1"
|
||||||
|
}`
|
||||||
|
|
||||||
|
i := &Item{}
|
||||||
|
err := json.Unmarshal([]byte(response), i)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Item Unmarshal failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
if i.Name != "Item" ||
|
||||||
|
i.Price != "22.99" ||
|
||||||
|
i.Currency != "GBP" ||
|
||||||
|
i.Quantity != "1" {
|
||||||
|
t.Errorf("Item decoded result is incorrect, Given: %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user