Update create-matrix.js
This commit is contained in:
parent
091d43c4f7
commit
002d8804df
|
@ -1,7 +1,8 @@
|
||||||
const { logger, db } = require('../core')
|
const { logger, db } = require('../core')
|
||||||
|
|
||||||
async function main() {
|
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) => {
|
const cluster_id = docs.reduce((acc, curr) => {
|
||||||
if (!acc.includes(curr.cluster_id)) acc.push(curr.cluster_id)
|
if (!acc.includes(curr.cluster_id)) acc.push(curr.cluster_id)
|
||||||
return acc
|
return acc
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { execSync } = require('child_process')
|
const { execSync } = require('child_process')
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db')
|
fs.emptyDirSync('tests/__data__/temp')
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/temp/streams.db')
|
||||||
fs.rmdirSync('tests/__data__/temp', { recursive: true })
|
|
||||||
fs.mkdirSync('tests/__data__/temp')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can create valid matrix', () => {
|
it('can create valid matrix', () => {
|
||||||
const result = execSync(
|
const result = execSync('DB_DIR=tests/__data__/temp node scripts/commands/create-matrix.js', {
|
||||||
'DB_FILEPATH=tests/__data__/temp/streams.db node scripts/commands/create-matrix.js',
|
encoding: 'utf8'
|
||||||
{ encoding: 'utf8' }
|
})
|
||||||
)
|
|
||||||
expect(result).toBe('::set-output name=matrix::{"cluster_id":[1,3]}\n')
|
expect(result).toBe('::set-output name=matrix::{"cluster_id":[1,3]}\n')
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue