-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
47 lines (36 loc) · 936 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
package tvdb
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/dashotv/tvdb/openapi/models/operations"
)
func TestLogin(t *testing.T) {
assert.NotEmpty(t, tvdbApiKey, "TVDB_API_KEY is empty")
c, err := Login(tvdbApiKey)
assert.NoError(t, err)
assert.NotNil(t, c)
}
func TestNew(t *testing.T) {
assert.NotEmpty(t, tvdbToken, "TVDB_API_TOKEN is empty")
c := New(tvdbApiKey, tvdbToken)
assert.NotNil(t, c)
}
func TestClient_Search(t *testing.T) {
assert.NotEmpty(t, tvdbApiKey, "TVDB_API_KEY is empty")
c, err := Login(tvdbApiKey)
assert.NoError(t, err)
assert.NotNil(t, c)
p := operations.GetSearchResultsRequest{
Query: String("The Simpsons"),
Type: String("series"),
}
r, err := c.GetSearchResults(p)
assert.NoError(t, err)
assert.NotNil(t, r)
for _, v := range r.Data {
assert.NotEmpty(t, *v.ID)
assert.NotEmpty(t, *v.Name)
fmt.Printf("%s: %s\n", *v.ID, *v.Name)
}
}