Update create-queue.test.js

This commit is contained in:
Aleksandr Statciuk 2022-01-31 05:23:39 +03:00
parent f147a74e44
commit 34eef8f525
3 changed files with 10 additions and 6 deletions

View file

@ -1,4 +1,2 @@
{"channel":{"lang":"en","xmltv_id":"CNNInternationalEurope2.us","site_id":"141","site":"example.com"},"configPath":"tests/__data__/input/sites/example.com.config.js","date":"2022-01-30T00:00:00.000Z","groups":["ca-nl/example.com"],"error":null,"cluster_id":1,"_id":"c4pT2p7Q4aBVh13M"}
{"channel":{"lang":"en","xmltv_id":"CNNInternationalEurope2.us","site_id":"141","site":"example.com"},"configPath":"tests/__data__/input/sites/example.com.config.js","date":"2022-01-31T00:00:00.000Z","groups":["ca-nl/example.com"],"error":null,"cluster_id":1,"_id":"POYAcMssTAgZu4Yk"}
{"channel":{"lang":"ru","xmltv_id":"CNNInternationalEurope.us","site_id":"140","site":"example.com"},"configPath":"tests/__data__/input/sites/example.com.config.js","date":"2022-01-30T00:00:00.000Z","groups":["ca-nl/example.com"],"error":null,"cluster_id":1,"_id":"TYDwYLsrkmPtTLT2"}
{"channel":{"lang":"ru","xmltv_id":"CNNInternationalEurope.us","site_id":"140","site":"example.com"},"configPath":"tests/__data__/input/sites/example.com.config.js","date":"2022-01-31T00:00:00.000Z","groups":["ca-nl/example.com"],"error":null,"cluster_id":1,"_id":"98cKRthEhMmKEnwx"}

View file

@ -0,0 +1 @@
{"xmltv_id":"CNNInternationalEurope2.us","site":"example.com","site_id":"141","lang":"en","error":"Wrong channel ID"}

View file

@ -7,7 +7,7 @@ beforeEach(() => {
fs.mkdirSync('tests/__data__/output')
const stdout = execSync(
'DB_DIR=tests/__data__/output/database CHANNELS_PATH=tests/__data__/input/sites/*.channels.xml node scripts/commands/create-queue.js --max-clusters=1 --days=2',
'DB_DIR=tests/__data__/output/database LOGS_DIR=tests/__data__/output/logs CHANNELS_PATH=tests/__data__/input/sites/*.channels.xml node scripts/commands/create-queue.js --max-clusters=1 --days=2',
{ encoding: 'utf8' }
)
})
@ -30,13 +30,18 @@ it('can create queue', () => {
expect(output).toEqual(
expect.arrayContaining([
expect.objectContaining(expected[0]),
expect.objectContaining(expected[1]),
expect.objectContaining(expected[2]),
expect.objectContaining(expected[3])
expect.objectContaining(expected[1])
])
)
})
it('can create errors log', () => {
let output = content('tests/__data__/output/logs/errors/ca-nl/example.com.log')
let expected = content('tests/__data__/expected/logs/errors/ca-nl/example.com.log')
expect(output).toEqual(expected)
})
function content(filepath) {
const data = fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'