aboutsummaryrefslogtreecommitdiff
path: root/pkg/navitia_api_client
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/navitia_api_client')
-rw-r--r--pkg/navitia_api_client/departures.go4
-rw-r--r--pkg/navitia_api_client/departures_test.go14
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)
}