-
Notifications
You must be signed in to change notification settings - Fork 8
/
league_test.go
35 lines (29 loc) · 984 Bytes
/
league_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
package opendota
import (
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLeagueService_Leagues(t *testing.T) {
httpClient, mux, server := testServer()
defer server.Close()
mux.HandleFunc("/api/leagues", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `[{"leagueid":2019,"ticket":"econ/leagues/subscriptions_ggleagues2ticket","banner":"econ/leagues/subscriptions_ggleagues2ticket_ingame","tier":"professional","name":"GG League Season 2 Ticket"}]`)
})
expected := []League{
{
LeagueID: 2019,
Ticket: "econ/leagues/subscriptions_ggleagues2ticket",
Banner: "econ/leagues/subscriptions_ggleagues2ticket_ingame",
Tier: "professional",
Name: "GG League Season 2 Ticket",
},
}
client := NewClient(httpClient)
leagues, _, err := client.LeagueService.Leagues()
assert.Nil(t, err)
assert.Equal(t, expected, leagues)
}