/
client_test.go
48 lines (42 loc) · 1021 Bytes
/
client_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
package client_test
import (
"errors"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
client "github.com/0ffsideCompass/api-football-go-client"
)
func TestNew(t *testing.T) {
type args struct {
key string
name string
client client.HttpClient
expectedError error
}
tests := []args{
{
name: "should return an error if the key is empty",
key: "",
client: &http.Client{},
expectedError: errors.New("missing key"),
},
{
name: "should return an error if the client is nil",
key: "123",
client: nil,
expectedError: errors.New("missing http client"),
},
{
name: "should return a client if the key is not empty",
client: &http.Client{},
key: "123",
expectedError: nil,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, err := client.New(test.key, test.client)
assert.Equal(t, test.expectedError, err)
})
}
}