@@ -6,15 +6,65 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
- func TestEmptyTableRequestOptions (t * testing.T ) {
10
- req := TableRequest {}
11
- assert .Empty (t , req .request ().options .encode ())
12
- }
13
-
14
- func TestNotEmptyTableRequestOptions (t * testing.T ) {
15
- req := TableRequest {
16
- Sources : []int {0 , 1 , 2 },
17
- Destinations : []int {1 , 3 },
9
+ func TestTableRequestOptions (t * testing.T ) {
10
+ cases := []struct {
11
+ name string
12
+ request TableRequest
13
+ expectedURI string
14
+ }{
15
+ {
16
+ name : "empty" ,
17
+ request : TableRequest {},
18
+ expectedURI : "" ,
19
+ },
20
+ {
21
+ name : "with sources and destinations" ,
22
+ request : TableRequest {
23
+ Sources : []int {0 , 1 , 2 },
24
+ Destinations : []int {1 , 3 },
25
+ },
26
+ expectedURI : "destinations=1;3&sources=0;1;2" ,
27
+ },
28
+ {
29
+ name : "scale_factor" ,
30
+ request : TableRequest {
31
+ ScaleFactor : 0.8 ,
32
+ GeneralOptions : GeneralOptions {
33
+ Exclude : []string {"toll" },
34
+ },
35
+ },
36
+ expectedURI : "exclude=toll&scale_factor=0.8" ,
37
+ },
38
+ {
39
+ name : "fallback_coordinate" ,
40
+ request : TableRequest {
41
+ FallbackSpeed : 11.5 ,
42
+ GeneralOptions : GeneralOptions {
43
+ Hints : []string {"a" , "b" },
44
+ },
45
+ },
46
+ expectedURI : "fallback_speed=11.5&hints=a;b" ,
47
+ },
48
+ {
49
+ name : "fallback_coordinate" ,
50
+ request : TableRequest {
51
+ FallbackSpeed : 11.5 ,
52
+ FallbackCoordinate : FallbackCoordinateInput ,
53
+ },
54
+ expectedURI : "fallback_coordinate=input&fallback_speed=11.5" ,
55
+ },
56
+ {
57
+ name : "annotations" ,
58
+ request : TableRequest {
59
+ Annotations : AnnotationsDurationDistance ,
60
+ FallbackSpeed : 11.5 ,
61
+ },
62
+ expectedURI : "annotations=duration%2Cdistance&fallback_speed=11.5" ,
63
+ },
64
+ }
65
+ for _ , c := range cases {
66
+ t .Run (c .name , func (t * testing.T ) {
67
+ assert .Equal (t , c .expectedURI , c .request .request ().options .encode ())
68
+ })
18
69
}
19
- assert .Equal (t , "destinations=1;3&sources=0;1;2" , req .request ().options .encode ())
20
70
}
0 commit comments