diff options
author | Julien Dessaux | 2021-04-06 16:46:05 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-04-06 16:46:05 +0200 |
commit | 92c5e1e4d073c82e12e26170379cb5c8d90ab2e8 (patch) | |
tree | d862f6ea5a3f22c6c8ad268c7ddf5bb2536fa95c /pkg/navitia_api_client | |
parent | Added a flag to specify a configuration file and wrote a proper readme (diff) | |
download | trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.tar.gz trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.tar.bz2 trains-92c5e1e4d073c82e12e26170379cb5c8d90ab2e8.zip |
Added trainStop config parameter which was wrongly hardcoded
Diffstat (limited to 'pkg/navitia_api_client')
-rw-r--r-- | pkg/navitia_api_client/departures.go | 4 | ||||
-rw-r--r-- | pkg/navitia_api_client/departures_test.go | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/pkg/navitia_api_client/departures.go b/pkg/navitia_api_client/departures.go index 7738940..cd75191 100644 --- a/pkg/navitia_api_client/departures.go +++ b/pkg/navitia_api_client/departures.go @@ -43,8 +43,8 @@ type DeparturesResponse struct { } `json:"context"` } -func (c *Client) GetDepartures() (departures *DeparturesResponse, err error) { - request := fmt.Sprintf("%s/coverage/sncf/stop_areas/stop_area:SNCF:87723502/departures", c.baseURL) +func (c *Client) GetDepartures(trainStop string) (departures *DeparturesResponse, err error) { + request := fmt.Sprintf("%s/coverage/sncf/stop_areas/%s/departures", c.baseURL, trainStop) start := time.Now() c.mutex.Lock() defer c.mutex.Unlock() diff --git a/pkg/navitia_api_client/departures_test.go b/pkg/navitia_api_client/departures_test.go index 14ffb96..e7d771f 100644 --- a/pkg/navitia_api_client/departures_test.go +++ b/pkg/navitia_api_client/departures_test.go @@ -9,20 +9,20 @@ import ( func TestGetDepartures(t *testing.T) { // invalid characters in token client := NewClient("}") - _, err := client.GetDepartures() + _, err := client.GetDepartures("test") if err == nil { - t.Fatalf("invalid characters in token should raise an error") + t.Fatalf("invalid characters in token should raise an error because the url is invalid") } // unreachable server client = NewClient("https://") - _, err = client.GetDepartures() + _, err = client.GetDepartures("test") if err == nil { t.Fatalf("unreachable server should raise an error") } // invalid json client, ts := newTestClientFromFilename(t, "test_data/invalid.json") defer ts.Close() - _, err = client.GetDepartures() + _, err = client.GetDepartures("test") if err == nil { t.Fatalf("invalid json should raise an error") } @@ -31,14 +31,14 @@ func TestGetDepartures(t *testing.T) { w.WriteHeader(http.StatusNotFound) })) client = newTestClient(ts) - _, err = client.GetDepartures() + _, err = client.GetDepartures("test") if err == nil { t.Fatalf("404 should raise an error") } // normal working request client, ts = newTestClientFromFilename(t, "test_data/normal-crepieux.json") defer ts.Close() - departures, err := client.GetDepartures() + departures, err := client.GetDepartures("test") if err != nil { t.Fatalf("could not get normal-crepieux departures : %s", err) } @@ -47,7 +47,7 @@ func TestGetDepartures(t *testing.T) { } // test the cache (assuming the test takes less than 60 seconds (and it really should) it will be accurate) ts.Close() - departures, err = client.GetDepartures() + departures, err = client.GetDepartures("test") if err != nil { t.Fatalf("could not get normal-crepieux departures : %s", err) } |