-
Notifications
You must be signed in to change notification settings - Fork 8
/
scenarios_test.go
93 lines (76 loc) · 2.18 KB
/
scenarios_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package opendota
import (
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestScenariosService_ItemTimings(t *testing.T) {
httpClient, mux, server := testServer()
defer server.Close()
mux.HandleFunc("/api/scenarios/itemTimings", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `[{"hero_id":1,"item":"butterfly","games":"166","wins":"105","time":1800}]`)
})
expected := []ItemTimings{
{
HeroID: 1,
Item: "butterfly",
Games: "166",
Wins: "105",
Time: 1800,
},
}
params := &ItemTimingsParam{}
client := NewClient(httpClient)
itemTimings, _, err := client.ScenariosService.ItemTimings(params)
assert.Nil(t, err)
assert.Equal(t, expected, itemTimings)
}
func TestScenariosService_LaneRoles(t *testing.T) {
httpClient, mux, server := testServer()
defer server.Close()
mux.HandleFunc("/api/scenarios/laneRoles", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `[{"hero_id":1,"lane_role":1,"games":"166","wins":"105","time":1800}]`)
})
expected := []LaneRoles{
{
HeroID: 1,
LaneRole: 1,
Games: "166",
Wins: "105",
Time: 1800,
},
}
params := &LaneRolesParam{}
client := NewClient(httpClient)
laneRoles, _, err := client.ScenariosService.LaneRoles(params)
assert.Nil(t, err)
assert.Equal(t, expected, laneRoles)
}
func TestScenariosService_Misc(t *testing.T) {
httpClient, mux, server := testServer()
defer server.Close()
mux.HandleFunc("/api/scenarios/misc", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `[{"scenario":"courier_kill","is_radiant":false,"region":1,"games":"840","wins":"442"}]`)
})
expected := []MiscQueryResults{
{
Scenario: "courier_kill",
IsRadiant: false,
Region: 1,
Games: "840",
Wins: "442",
},
}
params := &MiscParam{}
client := NewClient(httpClient)
misc, _, err := client.ScenariosService.Misc(params)
assert.Nil(t, err)
assert.Equal(t, expected, misc)
}