add first test

This commit is contained in:
JBP
2019-06-29 23:01:28 +02:00
parent b2dc7a86fd
commit d2d6f622f6
6 changed files with 318 additions and 5 deletions
+13
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"github.com/jybp/ebay"
@@ -66,3 +67,15 @@ func TestCheckResponse(t *testing.T) {
assert.Equal(t, "itemId", err.Errors[0].Parameters[0].Name)
assert.Equal(t, "2200077988|0", err.Errors[0].Parameters[0].Value)
}
// setup sets up a test HTTP server
func setup(t *testing.T) (client *ebay.Client, mux *http.ServeMux, teardown func()) {
mux = http.NewServeMux()
server := httptest.NewServer(mux)
var err error
client, err = ebay.NewCustomClient(nil, server.URL+"/")
if err != nil {
t.Fatal(err)
}
return client, mux, server.Close
}