test_helpers.go raw
1 package rest
2
3 import (
4 "net/http"
5 "net/http/httptest"
6 "testing"
7 )
8
9 // setup creates a test HTTP server and a client configured to use it
10 func setup(t *testing.T) (*Client, *httptest.Server, *http.ServeMux) {
11 mux := http.NewServeMux()
12 server := httptest.NewServer(mux)
13
14 client := NewClient(http.DefaultClient,
15 SetEndpoint(server.URL),
16 SetAPIKey("test-key"))
17
18 return client, server, mux
19 }
20