From 34eef8f525e3cf7ec34fcad74056e98f8856d6a6 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 31 Jan 2022 05:23:39 +0300 Subject: [PATCH] Update create-queue.test.js --- tests/__data__/expected/database/queue.db | 2 -- .../expected/logs/errors/ca-nl/example.com.log | 1 + tests/commands/create-queue.test.js | 13 +++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 tests/__data__/expected/logs/errors/ca-nl/example.com.log diff --git a/tests/__data__/expected/database/queue.db b/tests/__data__/expected/database/queue.db index 93a387bd..4680eb70 100644 --- a/tests/__data__/expected/database/queue.db +++ b/tests/__data__/expected/database/queue.db @@ -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"} diff --git a/tests/__data__/expected/logs/errors/ca-nl/example.com.log b/tests/__data__/expected/logs/errors/ca-nl/example.com.log new file mode 100644 index 00000000..26fae7bf --- /dev/null +++ b/tests/__data__/expected/logs/errors/ca-nl/example.com.log @@ -0,0 +1 @@ +{"xmltv_id":"CNNInternationalEurope2.us","site":"example.com","site_id":"141","lang":"en","error":"Wrong channel ID"} diff --git a/tests/commands/create-queue.test.js b/tests/commands/create-queue.test.js index c6212651..82a911f9 100644 --- a/tests/commands/create-queue.test.js +++ b/tests/commands/create-queue.test.js @@ -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'