-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathschema_test.go
38 lines (32 loc) · 883 Bytes
/
schema_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
package opendota
import (
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSchemaService_Schema(t *testing.T) {
httpClient, mux, server := testServer()
defer server.Close()
mux.HandleFunc("/api/schema", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `[{"table_name":"team_rating","column_name":"team_id","data_type":"bigint"},{"table_name":"team_rating","column_name":"rating","data_type":"real"}]`)
})
expected := []Schema{
{
TableName: "team_rating",
ColumnName: "team_id",
DataType: "bigint",
},
{
TableName: "team_rating",
ColumnName: "rating",
DataType: "real",
},
}
client := NewClient(httpClient)
schema, _, err := client.SchemaService.Schema()
assert.Nil(t, err)
assert.Equal(t, expected, schema)
}