aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-03 21:03:51 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-03 21:03:51 +0200
commit6d8ada5f24b245d3c84d29d65013f5315cbeff27 (patch)
tree2b4fdb38353279927c013219c03cbbe109086931 /server/tests
parent17c912d9b111eb4af3ff171a23dc866f76dc4fab (diff)
downloadPeerTube-6d8ada5f24b245d3c84d29d65013f5315cbeff27.tar.gz
PeerTube-6d8ada5f24b245d3c84d29d65013f5315cbeff27.tar.zst
PeerTube-6d8ada5f24b245d3c84d29d65013f5315cbeff27.zip
Better tests for a better world
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/multiplePods.js46
-rw-r--r--server/tests/api/singlePod.js6
-rw-r--r--server/tests/api/users.js5
3 files changed, 43 insertions, 14 deletions
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index b6545ca60..ba4ce70c9 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -96,6 +96,12 @@ describe('Test multiple pods', function () {
96 expect(video.podUrl).to.equal('http://localhost:9001') 96 expect(video.podUrl).to.equal('http://localhost:9001')
97 expect(video.magnetUri).to.exist 97 expect(video.magnetUri).to.exist
98 98
99 if (server.url !== 'http://localhost:9001') {
100 expect(video.isLocal).to.be.false
101 } else {
102 expect(video.isLocal).to.be.true
103 }
104
99 // All pods should have the same magnet Uri 105 // All pods should have the same magnet Uri
100 if (base_magnet === null) { 106 if (base_magnet === null) {
101 base_magnet = video.magnetUri 107 base_magnet = video.magnetUri
@@ -139,6 +145,12 @@ describe('Test multiple pods', function () {
139 expect(video.podUrl).to.equal('http://localhost:9002') 145 expect(video.podUrl).to.equal('http://localhost:9002')
140 expect(video.magnetUri).to.exist 146 expect(video.magnetUri).to.exist
141 147
148 if (server.url !== 'http://localhost:9002') {
149 expect(video.isLocal).to.be.false
150 } else {
151 expect(video.isLocal).to.be.true
152 }
153
142 // All pods should have the same magnet Uri 154 // All pods should have the same magnet Uri
143 if (base_magnet === null) { 155 if (base_magnet === null) {
144 base_magnet = video.magnetUri 156 base_magnet = video.magnetUri
@@ -178,23 +190,31 @@ describe('Test multiple pods', function () {
178 const videos = res.body 190 const videos = res.body
179 expect(videos).to.be.an('array') 191 expect(videos).to.be.an('array')
180 expect(videos.length).to.equal(4) 192 expect(videos.length).to.equal(4)
181 let video = videos[2] 193 const video1 = videos[2]
182 expect(video.name).to.equal('my super name for pod 3') 194 expect(video1.name).to.equal('my super name for pod 3')
183 expect(video.description).to.equal('my super description for pod 3') 195 expect(video1.description).to.equal('my super description for pod 3')
184 expect(video.podUrl).to.equal('http://localhost:9003') 196 expect(video1.podUrl).to.equal('http://localhost:9003')
185 expect(video.magnetUri).to.exist 197 expect(video1.magnetUri).to.exist
186 198
187 video = videos[3] 199 const video2 = videos[3]
188 expect(video.name).to.equal('my super name for pod 3-2') 200 expect(video2.name).to.equal('my super name for pod 3-2')
189 expect(video.description).to.equal('my super description for pod 3-2') 201 expect(video2.description).to.equal('my super description for pod 3-2')
190 expect(video.podUrl).to.equal('http://localhost:9003') 202 expect(video2.podUrl).to.equal('http://localhost:9003')
191 expect(video.magnetUri).to.exist 203 expect(video2.magnetUri).to.exist
204
205 if (server.url !== 'http://localhost:9003') {
206 expect(video1.isLocal).to.be.false
207 expect(video2.isLocal).to.be.false
208 } else {
209 expect(video1.isLocal).to.be.true
210 expect(video2.isLocal).to.be.true
211 }
192 212
193 // All pods should have the same magnet Uri 213 // All pods should have the same magnet Uri
194 if (base_magnet === null) { 214 if (base_magnet === null) {
195 base_magnet = video.magnetUri 215 base_magnet = video2.magnetUri
196 } else { 216 } else {
197 expect(video.magnetUri).to.equal.magnetUri 217 expect(video2.magnetUri).to.equal.magnetUri
198 } 218 }
199 219
200 callback() 220 callback()
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index 64d5475dd..efd8a64bc 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -72,6 +72,8 @@ describe('Test a single pod', function () {
72 expect(video.description).to.equal('my super description') 72 expect(video.description).to.equal('my super description')
73 expect(video.podUrl).to.equal('http://localhost:9001') 73 expect(video.podUrl).to.equal('http://localhost:9001')
74 expect(video.magnetUri).to.exist 74 expect(video.magnetUri).to.exist
75 expect(video.author).to.equal('root')
76 expect(video.isLocal).to.be.true
75 77
76 video_id = video.id 78 video_id = video.id
77 79
@@ -97,6 +99,8 @@ describe('Test a single pod', function () {
97 expect(video.description).to.equal('my super description') 99 expect(video.description).to.equal('my super description')
98 expect(video.podUrl).to.equal('http://localhost:9001') 100 expect(video.podUrl).to.equal('http://localhost:9001')
99 expect(video.magnetUri).to.exist 101 expect(video.magnetUri).to.exist
102 expect(video.author).to.equal('root')
103 expect(video.isLocal).to.be.true
100 104
101 webtorrent.add(video.magnetUri, function (torrent) { 105 webtorrent.add(video.magnetUri, function (torrent) {
102 expect(torrent.files).to.exist 106 expect(torrent.files).to.exist
@@ -119,6 +123,8 @@ describe('Test a single pod', function () {
119 expect(video.name).to.equal('my super name') 123 expect(video.name).to.equal('my super name')
120 expect(video.description).to.equal('my super description') 124 expect(video.description).to.equal('my super description')
121 expect(video.podUrl).to.equal('http://localhost:9001') 125 expect(video.podUrl).to.equal('http://localhost:9001')
126 expect(video.author).to.equal('root')
127 expect(video.isLocal).to.be.true
122 128
123 done() 129 done()
124 }) 130 })
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index 2c97f75d4..e5395a79f 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -98,7 +98,10 @@ describe('Test users', function () {
98 utils.getVideosList(server.url, function (err, res) { 98 utils.getVideosList(server.url, function (err, res) {
99 if (err) throw err 99 if (err) throw err
100 100
101 video_id = res.body[0].id 101 const video = res.body[0]
102 expect(video.author).to.equal('root')
103
104 video_id = video.id
102 done() 105 done()
103 }) 106 })
104 }) 107 })