mirror of
https://github.com/cubixle/ebay.git
synced 2026-04-30 11:28:45 +01:00
Add CheckCompatibility and GetItemByGroupID
This commit is contained in:
@@ -3,6 +3,7 @@ package ebay_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@@ -70,3 +71,46 @@ func TestGettItem(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "PRODUCT", item.ItemID)
|
||||
}
|
||||
|
||||
func TestGetItemByGroupID(t *testing.T) {
|
||||
client, mux, teardown := setup(t)
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/buy/browse/v1/item/get_items_by_item_group", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" {
|
||||
t.Fatalf("expected GET method, got: %s", r.Method)
|
||||
}
|
||||
fmt.Fprintf(w, `{"items": [{"itemId": "%s"}]}`, r.URL.Query().Get("item_group_id"))
|
||||
})
|
||||
|
||||
it, err := client.Buy.Browse.GetItemByGroupID(context.Background(), "151915076499")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "151915076499", it.Items[0].ItemID)
|
||||
}
|
||||
|
||||
func TestCheckCompatibility(t *testing.T) {
|
||||
client, mux, teardown := setup(t)
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/buy/browse/v1/item/v1|202117468662|0/check_compatibility", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
t.Fatalf("expected POST method, got: %s", r.Method)
|
||||
}
|
||||
assert.Equal(t, ebay.BuyMarketplaceUSA, r.Header.Get("X-EBAY-C-MARKETPLACE-ID"))
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("%+v", err)
|
||||
}
|
||||
assert.Equal(t, `{"compatibilityProperties":[{"name":"0","value":"1"},{"name":"2","value":"3"}]}
|
||||
`, string(body))
|
||||
fmt.Fprintf(w, `{"compatibilityStatus": "NOT_COMPATIBLE", "warnings": [{"category" : "category"}]}`)
|
||||
})
|
||||
compatibilityProperties := []ebay.CompatibilityProperty{
|
||||
{Name: "0", Value: "1"},
|
||||
{Name: "2", Value: "3"},
|
||||
}
|
||||
compatibility, err := client.Buy.Browse.CheckCompatibility(context.Background(), "v1|202117468662|0", ebay.BuyMarketplaceUSA, compatibilityProperties)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "NOT_COMPATIBLE", compatibility.CompatibilityStatus)
|
||||
assert.Equal(t, "category", compatibility.Warnings[0].Category)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user