From bb5b7dd3f5490c97e23c392a240face4f911e190 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 4 May 2021 15:50:49 +0200 Subject: Reworked the navitia_api_client to be mockable --- pkg/navitia_api_client/client_test.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'pkg/navitia_api_client/client_test.go') diff --git a/pkg/navitia_api_client/client_test.go b/pkg/navitia_api_client/client_test.go index df23790..009712d 100644 --- a/pkg/navitia_api_client/client_test.go +++ b/pkg/navitia_api_client/client_test.go @@ -9,15 +9,15 @@ import ( ) // package utilities -func newTestClient(ts *httptest.Server) *Client { - return &Client{ +func newTestClient(ts *httptest.Server) *NavitiaClient { + return &NavitiaClient{ baseURL: fmt.Sprintf(ts.URL), httpClient: ts.Client(), cache: make(map[string]cachedResult), } } -func newTestClientFromFilename(t *testing.T, filename string) (*Client, *httptest.Server) { +func newTestClientFromFilename(t *testing.T, filename string) (*NavitiaClient, *httptest.Server) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { page, err := ioutil.ReadFile(filename) if err != nil { @@ -27,12 +27,3 @@ func newTestClientFromFilename(t *testing.T, filename string) (*Client, *httptes })) return newTestClient(ts), ts } - -// tests -func TestNewClient(t *testing.T) { - client := NewClient("test") - want := "https://test@api.sncf.com/v1" - if client.baseURL != want { - t.Fatal("Invalid new client") - } -} -- cgit v1.2.3