fix(tests): rutor test

This commit is contained in:
Alexey Kasyanchuk 2018-09-02 05:19:43 +03:00
parent 73fd698020
commit 851391e187
4 changed files with 38 additions and 1 deletions

View File

@ -13,7 +13,8 @@ module.exports = class Rutor
{
this.p2p = props.p2p
this.dataDirectory = props.dataDirectory
setTimeout(() => this.recheck(), 30000)
let t = setTimeout(() => this.recheck(), 30000)
t.unref()
}
name() { return 'rutor' }
@ -61,6 +62,7 @@ module.exports = class Rutor
{
let data = JSON.parse(fs.readFileSync(this.dataDirectory + '/rutor/rutor.x.json'))
this.rutorMap = data.hashes
logT('rutor', 'add records to', Object.keys(this.rutorMap).length)
}
else
this.rutorMap = {}

View File

@ -0,0 +1,24 @@
const { assert } = require('chai')
const Rutor = require('../../src/background/strategies/rutor.js')
describe("rutor", () => {
let rutor = new Rutor({dataDirectory: 'tests/strategies'});
it("findHash", async function() {
const data = await rutor.findHash('7ea9e38a48a8d8f4e1a6807e02dda204bd90c94a')
assert.equal(data.name, 'DJ Farta - Пацанская сборка в тачку. Vol 8 (2015) MP3')
assert.equal(data.poster, 'http://s016.radikal.ru/i337/1509/72/f76a929da813.jpg')
assert(data.description.includes('Tracklist'), 'description must contrain equal string')
})
it("findHash second", async function() {
const data = await rutor.findHash('158448f6afbedb079aaf3c4695fb43e7dfa54515')
assert.equal(data.name, 'Наруто: Ураганные Хроники / Naruto Shippuuden Movie [4 фильм] (2007) DVDRip')
assert.equal(data.rutorThreadId, 5850)
})
it("notFound", async function() {
assert(!await rutor.findHash('90296af2742232ba80e4a1f335fc2e159011d0da'))
})
});

View File

@ -0,0 +1,5 @@
{
"hashes": {
"158448f6afbedb079aaf3c4695fb43e7dfa54515": 5850
}
}

View File

@ -0,0 +1,6 @@
{
"hashes": {
"158448f6afbedb079aaf3c4695fb43e7dfa54515": 5850,
"7ea9e38a48a8d8f4e1a6807e02dda204bd90c94a": 457419
}
}