mirror of
https://github.com/cubixle/ebay.git
synced 2026-04-30 03:08:41 +01:00
Add tests and continue integration test
This commit is contained in:
+28
-2
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestOptBrowseContextualLocationn(t *testing.T) {
|
||||
func TestOptBrowseContextualLocation(t *testing.T) {
|
||||
r, _ := http.NewRequest("", "", nil)
|
||||
ebay.OptBrowseContextualLocation("US", "19406")(r)
|
||||
assert.Equal(t, "contextualLocation=country%3DUS%2Czip%3D19406", r.Header.Get("X-EBAY-C-ENDUSERCTX"))
|
||||
@@ -23,7 +23,20 @@ func TestOptBrowseContextualLocationExistingHeader(t *testing.T) {
|
||||
assert.Equal(t, "affiliateCampaignId=1,contextualLocation=country%3DUS%2Czip%3D19406", r.Header.Get("X-EBAY-C-ENDUSERCTX"))
|
||||
}
|
||||
|
||||
func TestGetItem(t *testing.T) {
|
||||
func TestGetLegacyItem(t *testing.T) {
|
||||
client, mux, teardown := setup(t)
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/buy/browse/v1/item/get_item_by_legacy_id", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, `{"itemId": "v1|%s|0"}`, r.URL.Query().Get("legacy_item_id"))
|
||||
})
|
||||
|
||||
item, err := client.Buy.Browse.GetItemByLegacyID(context.Background(), "202117468662")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "v1|202117468662|0", item.ItemID)
|
||||
}
|
||||
|
||||
func TestGetCompactItem(t *testing.T) {
|
||||
client, mux, teardown := setup(t)
|
||||
defer teardown()
|
||||
|
||||
@@ -35,3 +48,16 @@ func TestGetItem(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "COMPACT", item.ItemID)
|
||||
}
|
||||
|
||||
func TestGettItem(t *testing.T) {
|
||||
client, mux, teardown := setup(t)
|
||||
defer teardown()
|
||||
|
||||
mux.HandleFunc("/buy/browse/v1/item/v1|202117468662|0", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, `{"itemId": "%s"}`, r.URL.Query().Get("fieldgroups"))
|
||||
})
|
||||
|
||||
item, err := client.Buy.Browse.GetItem(context.Background(), "v1|202117468662|0")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "PRODUCT", item.ItemID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user