From 1a42c9e2c0fb64cdbebd81b311736e752f591e0a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 18 Jul 2016 17:17:52 +0200 Subject: Server: udpate async to 2.0.0 --- server/tests/api/checkParams.js | 4 ++-- server/tests/api/friendsAdvanced.js | 17 +++++++++-------- server/tests/api/friendsBasic.js | 17 +++++++++-------- server/tests/api/multiplePods.js | 25 +++++++++++++------------ server/tests/api/singlePod.js | 9 +++++---- server/tests/api/users.js | 4 ++-- server/tests/real-world/real-world.js | 11 ++++++----- 7 files changed, 46 insertions(+), 41 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js index 7f22a37cc..c1ba9c2c0 100644 --- a/server/tests/api/checkParams.js +++ b/server/tests/api/checkParams.js @@ -1,10 +1,10 @@ 'use strict' -const async = require('async') const chai = require('chai') const expect = chai.expect const pathUtils = require('path') const request = require('supertest') +const series = require('async/series') const utils = require('./utils') @@ -57,7 +57,7 @@ describe('Test parameters validator', function () { before(function (done) { this.timeout(20000) - async.series([ + series([ function (next) { utils.flushTests(next) }, diff --git a/server/tests/api/friendsAdvanced.js b/server/tests/api/friendsAdvanced.js index b082270ff..603fbc16b 100644 --- a/server/tests/api/friendsAdvanced.js +++ b/server/tests/api/friendsAdvanced.js @@ -1,8 +1,9 @@ 'use strict' -const async = require('async') const chai = require('chai') +const each = require('async/each') const expect = chai.expect +const series = require('async/series') const utils = require('./utils') @@ -45,7 +46,7 @@ describe('Test advanced friends', function () { utils.flushAndRunMultipleServers(6, function (serversRun, urlsRun) { servers = serversRun - async.each(servers, function (server, callbackEach) { + each(servers, function (server, callbackEach) { utils.loginAndGetAccessToken(server, function (err, accessToken) { if (err) return callbackEach(err) @@ -59,7 +60,7 @@ describe('Test advanced friends', function () { it('Should make friends with two pod each in a different group', function (done) { this.timeout(20000) - async.series([ + series([ // Pod 3 makes friend with the first one function (next) { makeFriends(3, next) @@ -93,7 +94,7 @@ describe('Test advanced friends', function () { it('Should quit all friends', function (done) { this.timeout(10000) - async.series([ + series([ function (next) { quitFriends(1, next) }, @@ -103,7 +104,7 @@ describe('Test advanced friends', function () { function (err) { if (err) throw err - async.each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) { + each([ 1, 2, 3, 4, 5, 6 ], function (i, callback) { getFriendsList(i, function (err, res) { if (err) throw err @@ -119,7 +120,7 @@ describe('Test advanced friends', function () { it('Should make friends with the pods 1, 2, 3', function (done) { this.timeout(150000) - async.series([ + series([ // Pods 1, 2, 3 and 4 become friends function (next) { makeFriends(2, next) @@ -132,7 +133,7 @@ describe('Test advanced friends', function () { }, // Check the pods 1, 2, 3 and 4 are friends function (next) { - async.each([ 1, 2, 3, 4 ], function (i, callback) { + each([ 1, 2, 3, 4 ], function (i, callback) { getFriendsList(i, function (err, res) { if (err) throw err @@ -211,7 +212,7 @@ describe('Test advanced friends', function () { it('Should pod 1 quit friends', function (done) { this.timeout(25000) - async.series([ + series([ // Upload a video on server 3 for aditionnal tests function (next) { uploadVideo(3, next) diff --git a/server/tests/api/friendsBasic.js b/server/tests/api/friendsBasic.js index 5b738ad39..c74a7f224 100644 --- a/server/tests/api/friendsBasic.js +++ b/server/tests/api/friendsBasic.js @@ -1,8 +1,9 @@ 'use strict' -const async = require('async') const chai = require('chai') +const each = require('async/each') const expect = chai.expect +const series = require('async/series') const utils = require('./utils') @@ -45,7 +46,7 @@ describe('Test basic friends', function () { utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) { servers = serversRun - async.each(servers, function (server, callbackEach) { + each(servers, function (server, callbackEach) { utils.loginAndGetAccessToken(server, function (err, accessToken) { if (err) return callbackEach(err) @@ -57,7 +58,7 @@ describe('Test basic friends', function () { }) it('Should not have friends', function (done) { - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { utils.getFriendsList(server.url, function (err, res) { if (err) throw err @@ -72,7 +73,7 @@ describe('Test basic friends', function () { it('Should make friends', function (done) { this.timeout(10000) - async.series([ + series([ // The second pod make friend with the third function (next) { makeFriends(2, next) @@ -119,7 +120,7 @@ describe('Test basic friends', function () { // Now each pod should be friend with the other ones function (err) { if (err) throw err - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { testMadeFriends(servers, server, callback) }, done) }) @@ -131,7 +132,7 @@ describe('Test basic friends', function () { }) it('Should quit friends of pod 2', function (done) { - async.series([ + series([ // Pod 1 quit friends function (next) { const server = servers[1] @@ -151,7 +152,7 @@ describe('Test basic friends', function () { }, // Other pods shouldn't have pod 1 too function (next) { - async.each([ servers[0].url, servers[2].url ], function (url, callback) { + each([ servers[0].url, servers[2].url ], function (url, callback) { utils.getFriendsList(url, function (err, res) { if (err) throw err @@ -169,7 +170,7 @@ describe('Test basic friends', function () { it('Should allow pod 2 to make friend again', function (done) { const server = servers[1] utils.makeFriends(server.url, server.accessToken, function () { - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { testMadeFriends(servers, server, callback) }, done) }) diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js index 2a1bc64e6..ac140f6bb 100644 --- a/server/tests/api/multiplePods.js +++ b/server/tests/api/multiplePods.js @@ -1,9 +1,10 @@ 'use strict' -const async = require('async') const chai = require('chai') +const each = require('async/each') const expect = chai.expect const pathUtils = require('path') +const series = require('async/series') const utils = require('./utils') const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) @@ -16,7 +17,7 @@ describe('Test multiple pods', function () { before(function (done) { this.timeout(30000) - async.series([ + series([ // Run servers function (next) { utils.flushAndRunMultipleServers(3, function (serversRun) { @@ -26,7 +27,7 @@ describe('Test multiple pods', function () { }, // Get the access tokens function (next) { - async.each(servers, function (server, callbackEach) { + each(servers, function (server, callbackEach) { utils.loginAndGetAccessToken(server, function (err, accessToken) { if (err) return callbackEach(err) @@ -56,7 +57,7 @@ describe('Test multiple pods', function () { }) it('Should not have videos for all pods', function (done) { - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { utils.getVideosList(server.url, function (err, res) { if (err) throw err @@ -73,7 +74,7 @@ describe('Test multiple pods', function () { it('Should upload the video on pod 1 and propagate on each pod', function (done) { this.timeout(15000) - async.series([ + series([ function (next) { const name = 'my super name for pod 1' const description = 'my super description for pod 1' @@ -88,7 +89,7 @@ describe('Test multiple pods', function () { function (err) { if (err) throw err - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { let baseMagnet = null utils.getVideosList(server.url, function (err, res) { @@ -135,7 +136,7 @@ describe('Test multiple pods', function () { it('Should upload the video on pod 2 and propagate on each pod', function (done) { this.timeout(15000) - async.series([ + series([ function (next) { const name = 'my super name for pod 2' const description = 'my super description for pod 2' @@ -150,7 +151,7 @@ describe('Test multiple pods', function () { function (err) { if (err) throw err - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { let baseMagnet = null utils.getVideosList(server.url, function (err, res) { @@ -197,7 +198,7 @@ describe('Test multiple pods', function () { it('Should upload two videos on pod 3 and propagate on each pod', function (done) { this.timeout(30000) - async.series([ + series([ function (next) { const name = 'my super name for pod 3' const description = 'my super description for pod 3' @@ -220,7 +221,7 @@ describe('Test multiple pods', function () { let baseMagnet = null // All pods should have this video - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { utils.getVideosList(server.url, function (err, res) { if (err) throw err @@ -372,7 +373,7 @@ describe('Test multiple pods', function () { it('Should remove the file 3 and 3-2 by asking pod 3', function (done) { this.timeout(15000) - async.series([ + series([ function (next) { utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next) }, @@ -387,7 +388,7 @@ describe('Test multiple pods', function () { }) it('Should have videos 1 and 3 on each pod', function (done) { - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { utils.getVideosList(server.url, function (err, res) { if (err) throw err diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js index 465a86b13..6ed719f87 100644 --- a/server/tests/api/singlePod.js +++ b/server/tests/api/singlePod.js @@ -1,11 +1,12 @@ 'use strict' -const async = require('async') const chai = require('chai') +const each = require('async/each') const expect = chai.expect const fs = require('fs') const keyBy = require('lodash/keyBy') const pathUtils = require('path') +const series = require('async/series') const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) webtorrent.silent = true @@ -20,7 +21,7 @@ describe('Test a single pod', function () { before(function (done) { this.timeout(20000) - async.series([ + series([ function (next) { utils.flushTests(next) }, @@ -280,7 +281,7 @@ describe('Test a single pod', function () { 'video_short.mp4', 'video_short.ogv', 'video_short.webm', 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' ] - async.each(videos, function (video, callbackEach) { + each(videos, function (video, callbackEach) { const name = video + ' name' const description = video + ' description' const tags = [ 'tag1', 'tag2', 'tag3' ] @@ -318,7 +319,7 @@ describe('Test a single pod', function () { // For the next test videosListBase = videos - async.each(videos, function (video, callbackEach) { + each(videos, function (video, callbackEach) { if (err) throw err const videoName = video.name.replace(' name', '') diff --git a/server/tests/api/users.js b/server/tests/api/users.js index 7ab426d85..749aa8af8 100644 --- a/server/tests/api/users.js +++ b/server/tests/api/users.js @@ -1,9 +1,9 @@ 'use strict' -const async = require('async') const chai = require('chai') const expect = chai.expect const pathUtils = require('path') +const series = require('async/series') const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) webtorrent.silent = true @@ -18,7 +18,7 @@ describe('Test users', function () { before(function (done) { this.timeout(20000) - async.series([ + series([ function (next) { utils.flushTests(next) }, diff --git a/server/tests/real-world/real-world.js b/server/tests/real-world/real-world.js index bc6ea859b..b28796852 100644 --- a/server/tests/real-world/real-world.js +++ b/server/tests/real-world/real-world.js @@ -1,8 +1,9 @@ 'use strict' -const async = require('async') -const program = require('commander') +const each = require('each') const isEqual = require('lodash/isEqual') +const program = require('commander') +const series = require('async/series') process.env.NODE_ENV = 'test' const constants = require('../../initializers/constants') @@ -93,7 +94,7 @@ function getRandomNumServer (servers) { function runServers (numberOfPods, callback) { let servers = null - async.series([ + series([ // Run servers function (next) { utils.flushAndRunMultipleServers(numberOfPods, function (serversRun) { @@ -103,7 +104,7 @@ function runServers (numberOfPods, callback) { }, // Get the access tokens function (next) { - async.each(servers, function (server, callbackEach) { + each(servers, function (server, callbackEach) { utils.loginAndGetAccessToken(server, function (err, accessToken) { if (err) return callbackEach(err) @@ -184,7 +185,7 @@ function remove (servers, numServer, callback) { function checkIntegrity (servers, callback) { const videos = [] - async.each(servers, function (server, callback) { + each(servers, function (server, callback) { utils.getAllVideosListBy(server.url, function (err, res) { if (err) throw err const serverVideos = res.body.data -- cgit v1.2.3