From c7dc04e1bb386a3d4748f9cbc380af92ad528d40 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 7 Feb 2022 06:18:31 +0300 Subject: [PATCH] Update load-cluster.js --- .github/workflows/auto-update.yml | 2 +- scripts/commands/{load-streams.js => load-cluster.js} | 7 ++++--- .../logs/{load-streams => load-cluster}/cluster_1.log | 0 .../{load-streams.test.js => load-cluster.test.js} | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) rename scripts/commands/{load-streams.js => load-cluster.js} (85%) rename tests/__data__/expected/logs/{load-streams => load-cluster}/cluster_1.log (100%) rename tests/commands/{load-streams.test.js => load-cluster.test.js} (58%) diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index 4d2a38477e..10bb3ced51 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -51,7 +51,7 @@ jobs: with: node-version: '14' - run: npm install - - run: node scripts/commands/load-streams.js --cluster-id=${{ matrix.cluster_id }} + - run: node scripts/commands/load-cluster.js --cluster-id=${{ matrix.cluster_id }} - uses: actions/upload-artifact@v2 with: name: logs diff --git a/scripts/commands/load-streams.js b/scripts/commands/load-cluster.js similarity index 85% rename from scripts/commands/load-streams.js rename to scripts/commands/load-cluster.js index 5e3e50caa9..57629c4f17 100644 --- a/scripts/commands/load-streams.js +++ b/scripts/commands/load-cluster.js @@ -15,7 +15,7 @@ const config = { debug: options.debug } -const LOGS_PATH = process.env.LOGS_PATH || 'scripts/logs/load-streams' +const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs/load-cluster' async function main() { logger.info('starting...') @@ -23,11 +23,12 @@ async function main() { logger.info(`delay: ${options.delay}ms`) timer.start() - const clusterLog = `${LOGS_PATH}/cluster_${options.clusterId}.log` + const clusterLog = `${LOGS_DIR}/cluster_${options.clusterId}.log` logger.info(`loading cluster: ${options.clusterId}`) logger.info(`creating '${clusterLog}'...`) await file.create(clusterLog) - const items = await db.find({ cluster_id: options.clusterId }) + await db.streams.load() + const items = await db.streams.find({ cluster_id: options.clusterId }) const total = items.length logger.info(`found ${total} links`) diff --git a/tests/__data__/expected/logs/load-streams/cluster_1.log b/tests/__data__/expected/logs/load-cluster/cluster_1.log similarity index 100% rename from tests/__data__/expected/logs/load-streams/cluster_1.log rename to tests/__data__/expected/logs/load-cluster/cluster_1.log diff --git a/tests/commands/load-streams.test.js b/tests/commands/load-cluster.test.js similarity index 58% rename from tests/commands/load-streams.test.js rename to tests/commands/load-cluster.test.js index 00bde95453..630e862fc0 100644 --- a/tests/commands/load-streams.test.js +++ b/tests/commands/load-cluster.test.js @@ -5,17 +5,17 @@ const { execSync } = require('child_process') beforeEach(() => { fs.emptyDirSync('tests/__data__/output') fs.emptyDirSync('tests/__data__/temp') - fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db') + fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/temp/streams.db') const stdout = execSync( - 'DB_FILEPATH=tests/__data__/temp/streams.db LOGS_PATH=tests/__data__/output/logs/load-streams node scripts/commands/load-streams.js --cluster-id=1 --timeout=1', + 'DB_DIR=tests/__data__/temp LOGS_DIR=tests/__data__/output/logs/load-cluster node scripts/commands/load-cluster.js --cluster-id=1 --timeout=1', { encoding: 'utf8' } ) }) it('return results', () => { - let output = content('tests/__data__/output/logs/load-streams/cluster_1.log') - let expected = content('tests/__data__/expected/logs/load-streams/cluster_1.log') + let output = content('tests/__data__/output/logs/load-cluster/cluster_1.log') + let expected = content('tests/__data__/expected/logs/load-cluster/cluster_1.log') expect(output).toEqual(expected) })