UNPKG

@artilleryio/platform-fargate

Version:
53 lines (37 loc) 1.31 kB
module.exports = { getTests }; const debug = require('debug')('commands:get-tests'); const createStore = require('../data-api/store'); const getBackendStore = require('../utils/get-backend-store'); const Table = require('cli-table3'); const setDefaultAWSCredentials = require('../utils/aws-set-default-credentials'); async function getTests(options) { await setDefaultAWSCredentials(); const store = createStore(await getBackendStore()); await store.init(); const runningTests = await store.getRunningTests(); debug(runningTests); let output = ''; if(options.json) { output = JSON.stringify({tests: Object.keys(runningTests).map(k => runningTests[k])}, null, 4); } if(!options.json) { const t = new Table({ head: [ 'test run id', 'region', 'cluster', 'launch type', 'workers', 'started at', 'name' ]}); for(const [id, r] of Object.entries(runningTests)) { t.push([ r.testRunId, r.metadata?.region, r.metadata?.cluster, r.metadata?.launchType, r.metadata?.count, new Date(r.startedAt).toLocaleString(), r.tags?.name ]); } output = t.toString(); } if (Object.keys(runningTests).length === 0 && !options.json) { console.log('no running tests'); } else { console.log(output); } }