forked from animenotifier/kitsu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kitsu_test.go
179 lines (138 loc) · 4 KB
/
kitsu_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package kitsu
import (
"testing"
"github.com/akyoto/assert"
)
func TestGetAnime(t *testing.T) {
anime, err := GetAnime("12268")
assert.Nil(t, err)
assert.NotNil(t, anime)
assert.NotEqual(t, anime.ID, "")
assert.NotEqual(t, anime.Attributes.Titles.EnJp, "")
assert.NotEqual(t, anime.Link(), "")
assert.NotEqual(t, anime.Attributes.PosterImage.Original, "")
assert.NotEqual(t, FixImageURL(anime.Attributes.PosterImage.Original), "")
}
func TestGetAnimeCharactersForAnime(t *testing.T) {
response, err := GetAnimeCharactersForAnime("12268")
assert.Nil(t, err)
assert.NotNil(t, response)
assert.NotNil(t, response.Data)
assert.NotEqual(t, response.Included, "")
}
func TestAnimePage(t *testing.T) {
page, err := GetAnimePage("anime?page[limit]=5&page[offset]=0")
assert.Nil(t, err)
for _, anime := range page.Data {
assert.NotEqual(t, anime.ID, "")
assert.NotEqual(t, anime.Attributes.Titles.EnJp, "")
assert.NotEqual(t, anime.Link(), "")
assert.NotEqual(t, anime.Attributes.PosterImage.Original, "")
assert.NotEqual(t, FixImageURL(anime.Attributes.PosterImage.Original), "")
}
}
func TestMappingPage(t *testing.T) {
page, err := GetMappingsPage("mappings?page[limit]=5&page[offset]=0&include=item")
assert.Nil(t, err)
for _, mapping := range page.Data {
assert.NotEqual(t, mapping.ID, "")
assert.NotEqual(t, mapping.Attributes.ExternalID, "")
assert.NotEqual(t, mapping.Attributes.ExternalSite, "")
assert.NotEqual(t, mapping.Relationships.Item.Data.ID, "")
}
}
func TestStreamAnime(t *testing.T) {
allAnime := StreamAnime()
count := 0
for anime := range allAnime {
assert.NotEqual(t, anime.ID, "")
assert.NotEqual(t, anime.Attributes.Titles.EnJp, "")
count++
if count >= 40 {
break
}
}
}
func TestStreamMediaRelations(t *testing.T) {
allRelations := StreamMediaRelations()
count := 0
for relation := range allRelations {
assert.NotEqual(t, relation.ID, "")
assert.NotEqual(t, relation.Attributes.Role, "")
assert.NotEqual(t, relation.Relationships.Source.Data.ID, "")
assert.NotEqual(t, relation.Relationships.Source.Data.Type, "")
assert.NotEqual(t, relation.Relationships.Destination.Data.ID, "")
assert.NotEqual(t, relation.Relationships.Destination.Data.Type, "")
count++
if count >= 40 {
break
}
}
}
func TestCharacterPage(t *testing.T) {
page, err := GetCharacterPage("characters?page[limit]=5&page[offset]=0")
assert.Nil(t, err)
for _, character := range page.Data {
assert.NotEqual(t, character.ID, "")
assert.NotEqual(t, character.Attributes.CanonicalName, "")
}
}
func TestStreamCharacters(t *testing.T) {
allCharacters := StreamCharacters()
count := 0
for character := range allCharacters {
assert.NotEqual(t, character.ID, "")
assert.NotEqual(t, character.Attributes.CanonicalName, "")
count++
if count >= 40 {
break
}
}
}
func TestStreamMappings(t *testing.T) {
allMappings := StreamMappings()
count := 0
for mapping := range allMappings {
assert.NotEqual(t, mapping.ID, "")
assert.NotEqual(t, mapping.Attributes.ExternalID, "")
assert.NotEqual(t, mapping.Attributes.ExternalSite, "")
assert.NotEqual(t, mapping.Relationships.Item.Data.ID, "")
count++
if count >= 40 {
break
}
}
}
func TestGetUser(t *testing.T) {
userName := "Akyoto"
user, err := GetUser(userName)
assert.NotNil(t, user)
assert.Nil(t, err)
assert.NotEqual(t, user.ID, "")
assert.NotEqual(t, user.Attributes.Name, "")
}
func TestGetUserError(t *testing.T) {
userName := "😀🙄😇"
user, err := GetUser(userName)
assert.Nil(t, user)
assert.NotNil(t, err)
}
func TestStreamUserLibrary(t *testing.T) {
userName := "Akyoto"
user, _ := GetUser(userName)
library := user.StreamLibraryEntries()
count := 0
for entry := range library {
assert.NotNil(t, entry)
assert.NotEqual(t, entry.Attributes.Status, "")
assert.NotEqual(t, entry.ID, "")
assert.NotEqual(t, entry.Attributes.Status, "")
if entry.Anime != nil {
assert.NotEqual(t, entry.Anime.Attributes.CanonicalTitle, "")
}
count++
if count >= 40 {
break
}
}
}