Add more GetBidding test and IsError

This commit is contained in:
JBP
2019-08-17 12:18:23 +02:00
parent 22c6e9d1bd
commit 1fb075c056
8 changed files with 193 additions and 60 deletions
+16
View File
@@ -1,6 +1,8 @@
package ebay_test
import (
"context"
"fmt"
"net/http"
"testing"
@@ -13,3 +15,17 @@ func TestOptBuyMarketplace(t *testing.T) {
ebay.OptBuyMarketplace("EBAY_US")(r)
assert.Equal(t, "EBAY_US", r.Header.Get("X-EBAY-C-MARKETPLACE-ID"))
}
func TestGetBidding(t *testing.T) {
client, mux, teardown := setup(t)
defer teardown()
mux.HandleFunc("/buy/offer/v1_beta/bidding/v1|202117468662|0", func(w http.ResponseWriter, r *http.Request) {
marketplaceID := r.Header.Get("X-EBAY-C-MARKETPLACE-ID")
fmt.Fprintf(w, `{"itemId": "%s"}`, marketplaceID)
})
bidding, err := client.Buy.Offer.GetBidding(context.Background(), "v1|202117468662|0", ebay.BuyMarketplaceUSA)
assert.Nil(t, err)
assert.Equal(t, ebay.BuyMarketplaceUSA, bidding.ItemID)
}