-
Notifications
You must be signed in to change notification settings - Fork 6
/
api_test.go
68 lines (59 loc) · 1.44 KB
/
api_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package itunes_search
import (
"testing"
)
// Simplest search example
func TestSearch(t *testing.T) {
res, _ := Search([]string{"Hello", "World"}).
Country(US).App().Limit(5).Results()
for _, r := range res {
r.Print()
}
}
// Simplest lookup example
func TestLookup(t *testing.T) {
res, _ := Lookup().ID(989673964).Result()
res.Print()
}
func TestLookupCNStoreByiTunesID(t *testing.T) {
testCase := []struct {
ID int64
ExpectName string
}{
{414478124, "微信"},
{534453594, "保卫萝卜1"},
{529479190, "部落冲突 (Clash of Clans)"},
{510940882, "找你妹"},
}
for _, c := range testCase {
if res, err := Lookup().ID(c.ID).Result(); err != nil {
t.Error(err)
} else {
// res.Print()
if res.TrackName != c.ExpectName {
t.Errorf("expect name of id %d is %s, got %s", c.ID, c.ExpectName, res.TrackName)
}
}
}
}
func TestLookupCNAppByBundleID(t *testing.T) {
testCase := []struct {
BundleID string
ExpectName string
}{
{"com.tencent.xin", "微信"},
{"cairot", "保卫萝卜1"},
{"com.supercell.magic", "部落冲突 (Clash of Clans)"},
{"com.funship.smarteye", "找你妹"},
}
for _, c := range testCase {
if res, err := Lookup().BundleID(c.BundleID).Country(CN).Result(); err != nil {
t.Error(err)
} else {
// res.Print()
if res.TrackName != c.ExpectName {
t.Errorf("expect name of bundleID %s is %s, got %s", c.BundleID, c.ExpectName, res.TrackName)
}
}
}
}