Last active
June 2, 2018 23:34
-
-
Save klamping/5c9f289cd14e3728d52efb53b205e9fe to your computer and use it in GitHub Desktop.
test run idea code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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