-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplaces_test.go
53 lines (44 loc) · 1.36 KB
/
places_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package navitia
import (
"context"
"reflect"
"testing"
"github.com/govitia/navitia/types"
)
func Test_Places(t *testing.T) {
if *apiKey == "" {
t.Skip(skipNoKey)
}
params := PlacesRequest{
Query: "avenue",
}
// Create the root context
ctx := context.Background()
// Run a simple search
t.Run("simple", func(t *testing.T) {
res, err := testSession.Places(ctx, params)
if err != nil {
t.Fatalf("error in Places: %v\n\tParameters: %#v\n\tReceived: %#v", err, params, res)
}
})
// Run a search with proximity
t.Run("proximity", func(t *testing.T) {
params.Around = types.Coordinates{
Latitude: 48.847002,
Longitude: 2.377310,
}
res, err := testSession.Places(ctx, params)
if err != nil {
t.Fatalf("error in Places: %v\n\tParameters: %#v\n\tReceived: %#v", err, params, res)
}
})
}
// Test_PlacesResults_Unmarshal tests unmarshalling for PlacesResults.
// As the unmarshalling is done by encoding/json, this allows us to check that the input can be reliably unmarshalled into the structure we have for it.
//
// This launches both a "correct" and "incorrect" subtest, allowing us to test both cases.
// If we expect no errors but we get one, the test fails
// If we expect an error but we don't get one, the test fails
func Test_PlacesResults_Unmarshal(t *testing.T) {
testUnmarshal(t, testData["places"], reflect.TypeOf(PlacesResults{}))
}