Skip to content

Instantly share code, notes, and snippets.

@klamping
Last active June 2, 2018 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klamping/5c9f289cd14e3728d52efb53b205e9fe to your computer and use it in GitHub Desktop.
Save klamping/5c9f289cd14e3728d52efb53b205e9fe to your computer and use it in GitHub Desktop.
test run idea code
const executeTest = require('./executeTest.js');
const dbSettings = {};
const db = new Database(dbSettings);
await db.init();
function initTest (userId, projectId, command, opts) {
const testRun = db.createTestrun(userId, {
projectId
command,
opts
});
const gitUrl = users.getProjectGitUrl(userId, projectId)
executeTest(testRun.id, gitUrl, command, opts);
return testRun.id;
}
const dbSettings = {};
const db = new Database(dbSettings);
async function executeTest (testRunId, gitUrl, command, opts) {
await db.init();
const testRun = db.getTestRun(testRunId);
const folder = `/tmp/run-{testRunId}`;
testRun.setStatus('cloning');
try {
await clone(gitUrl, folder);
} catch (e) {
testRun.setStatus('error cloning', e);
}
testRun.setStatus('installing');
try {
await npm(folder);
} catch (e) {
testRun.setStatus('error installing', e);
}
testRun.setStatus('running tests');
let results;
try {
results = await runTest(folder, command, opts);
} catch (e) {
testRun.setStatus('error running test', e);
}
testRun.storeResults(results);
testRun.setStatus('creating report');
try {
const report = await createReport(folder);
} catch (e) {
testRun.setStatus('error creating report', e);
}
testRun.storeReport(report);
testRun.setStatus('complete');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment