diff options
Diffstat (limited to '')
-rw-r--r-- | pkg/navitia_api_client/client_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/navitia_api_client/client_test.go b/pkg/navitia_api_client/client_test.go index 009712d..d63db9e 100644 --- a/pkg/navitia_api_client/client_test.go +++ b/pkg/navitia_api_client/client_test.go @@ -27,3 +27,28 @@ func newTestClientFromFilename(t *testing.T, filename string) (*NavitiaClient, * })) return newTestClient(ts), ts } + +type testClientCase struct { + urlPath string + filename string +} + +func newTestClientFromFilenames(t *testing.T, tcs []testClientCase) (*NavitiaClient, *httptest.Server) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + found := false + for i := 0; i < len(tcs) && !found; i++ { + if r.URL.Path+"?"+r.URL.RawQuery == tcs[i].urlPath { + page, err := ioutil.ReadFile(tcs[i].filename) + if err != nil { + t.Fatalf("Could not open test file : %s", err) + } + w.Write(page) + found = true + } + } + if !found { + http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) + } + })) + return newTestClient(ts), ts +} |