From 002d8804df10af197dc89ba64a654a4e8c3ba8ca Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 7 Feb 2022 06:11:40 +0300 Subject: [PATCH] Update create-matrix.js --- scripts/commands/create-matrix.js | 3 ++- tests/commands/create-matrix.test.js | 16 ++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/commands/create-matrix.js b/scripts/commands/create-matrix.js index be639b0287..486111db6a 100644 --- a/scripts/commands/create-matrix.js +++ b/scripts/commands/create-matrix.js @@ -1,7 +1,8 @@ const { logger, db } = require('../core') async function main() { - const docs = await db.find({}).sort({ cluster_id: 1 }) + await db.streams.load() + const docs = await db.streams.find({}).sort({ cluster_id: 1 }) const cluster_id = docs.reduce((acc, curr) => { if (!acc.includes(curr.cluster_id)) acc.push(curr.cluster_id) return acc diff --git a/tests/commands/create-matrix.test.js b/tests/commands/create-matrix.test.js index b02bf02540..07f0106f70 100644 --- a/tests/commands/create-matrix.test.js +++ b/tests/commands/create-matrix.test.js @@ -1,20 +1,16 @@ -const fs = require('fs') +const fs = require('fs-extra') const path = require('path') const { execSync } = require('child_process') beforeEach(() => { - fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db') -}) + fs.emptyDirSync('tests/__data__/temp') -afterEach(() => { - fs.rmdirSync('tests/__data__/temp', { recursive: true }) - fs.mkdirSync('tests/__data__/temp') + fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/temp/streams.db') }) it('can create valid matrix', () => { - const result = execSync( - 'DB_FILEPATH=tests/__data__/temp/streams.db node scripts/commands/create-matrix.js', - { encoding: 'utf8' } - ) + const result = execSync('DB_DIR=tests/__data__/temp node scripts/commands/create-matrix.js', { + encoding: 'utf8' + }) expect(result).toBe('::set-output name=matrix::{"cluster_id":[1,3]}\n') })