tvdb - search_test.go
1 package tvdb_test
2
3 import "testing"
4
5 func TestSearch(t *testing.T) {
6 t.Parallel()
7 tests := []struct {
8 Name string
9 IDs []uint64
10 }{
11 {
12 "Red Dwarf",
13 []uint64{71326},
14 },
15 {
16 "Coupling",
17 []uint64{78131, 70905},
18 },
19 }
20
21 for n, test := range tests {
22 results, err := conn.Search(test.Name)
23 if err != nil {
24 t.Errorf("test %d: unexpected error: %s", n+1, err)
25 continue
26 }
27 Loop:
28 for _, id := range test.IDs {
29 for _, result := range results {
30 if id == result.ID {
31 continue Loop
32 }
33 }
34 t.Errorf("test %d: didn't find ID %d", n+1, id)
35 }
36 }
37 }
38
39 func TestIMDB(t *testing.T) {
40 t.Parallel()
41 tests := []struct {
42 IMDBID string
43 ID uint64
44 }{
45 {
46 "tt0094535",
47 71326,
48 },
49 {
50 "tt0237123",
51 78131,
52 },
53 }
54
55 for n, test := range tests {
56 result, err := conn.SearchIMDB(test.IMDBID)
57 if err != nil {
58 t.Errorf("test %d: unexpected error: %s", n+1, err)
59 continue
60 }
61 if result.ID != test.ID {
62 t.Errorf("test %d: expecting ID %d, got %d", n+1, test.ID, result.ID)
63 }
64 }
65 }