mirror of
https://github.com/cubixle/ebay.git
synced 2026-04-30 06:48:40 +01:00
add first test
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package ebay_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@@ -20,3 +22,17 @@ func TestOptBrowseContextualLocationExistingHeader(t *testing.T) {
|
||||
ebay.OptBrowseContextualLocation("US", "19406")(r)
|
||||
assert.Equal(t, "affiliateCampaignId=1,contextualLocation=country%3DUS%2Czip%3D19406", r.Header.Get("X-EBAY-C-ENDUSERCTX"))
|
||||
}
|
||||
|
||||
func TestGetItem(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": "v1|202117468662|0", "title": "%s"}`, r.URL.Query().Get("fieldgroups"))
|
||||
})
|
||||
|
||||
item, err := client.Buy.Browse.GetItem(context.Background(), "v1|202117468662|0", "COMPACT")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "v1|202117468662|0", item.ItemID)
|
||||
assert.Equal(t, "COMPACT", item.Title)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user