-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_test.go
94 lines (77 loc) · 2.15 KB
/
core_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
package main
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("gonico core test", func() {
Describe("test GetVideoThumbResponse function", func() {
var (
resp NicoVideoThumbResponse
err error
)
Context("when the video is deleted", func() {
BeforeEach(func() {
resp, err = GetVideoThumbResponse("sm1")
if err != nil {
Fail("Network connection error!!!")
}
})
It("should return ErrorInfo which tells the video is deleted", func() {
errorInfo := resp.ErrorInfo
Expect(errorInfo.Code).To(Equal("DELETED"))
Expect(errorInfo.Description).To(Equal("deleted"))
})
})
Context("when the video is alive", func() {
BeforeEach(func() {
resp, err = GetVideoThumbResponse("sm9")
})
It("should return VideoInfo", func() {
videoInfo := resp.VideoInfo
Expect(videoInfo.VideoId).To(Equal("sm9"))
Expect(videoInfo.MovieType).To(Equal("flv"))
})
})
})
Describe("test GetVideoTitle function", func() {
var title string
Context("when the video is deleted", func() {
BeforeEach(func() {
title = GetVideoTitle("sm1")
})
It("should return empty value", func() {
Expect(title).To(BeEmpty())
})
})
Context("when the video is alive", func() {
BeforeEach(func() {
title = GetVideoTitle("sm9")
})
It("should return correct value", func() {
Expect(title).To(ContainSubstring("陰陽師"))
})
})
})
Describe("test GetAllKindsOfVideoTags function", func() {
var allTags, lockedTags, unlockedTags []string
Context("when the video is deleted", func() {
BeforeEach(func() {
allTags, lockedTags, unlockedTags = GetAllKindsOfVideoTags("sm1")
})
It("should return empty value", func() {
Expect(allTags).To(BeEmpty())
Expect(lockedTags).To(BeEmpty())
Expect(unlockedTags).To(BeEmpty())
})
})
Context("when the video is alive", func() {
BeforeEach(func() {
allTags, lockedTags, unlockedTags = GetAllKindsOfVideoTags("sm9")
})
It("should return correct kinds of video tags", func() {
Expect(allTags[0]).To(Equal("陰陽師"))
Expect(lockedTags[0]).To(Equal("陰陽師"))
})
})
})
})