Update create-matrix.js
This commit is contained in:
parent
091d43c4f7
commit
002d8804df
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue