Created
August 1, 2016 12:18
-
-
Save grncdr/e020a8fe371fbf6108f4b4bf0b2be944 to your computer and use it in GitHub Desktop.
Find errors from runscope
This file contains hidden or 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
#!/usr/bin/env node | |
const https = require('https') | |
const accessToken = 'ACCESS_TOKEN' | |
const bucket = 'BUCKET_KEY' | |
const testId = 'TEST_ID' | |
function formatLink (result) { | |
const start = new Date(result.started_at * 1000).toISOString() | |
return `[${start}|https://www.runscope.com/radar/${result.bucket_key}/${result.test_id}/history/${result.test_run_id}]` | |
} | |
function next (before) { | |
const search = before ? ('&before=' + before) : '' | |
const buffs = [] | |
// console.error({before}) | |
https.get({ | |
hostname: 'api.runscope.com', | |
path: `/buckets/${bucket}/tests/${testId}/results?count=50` + search, | |
headers: { Authorization: 'Bearer ${accessToken}' }, | |
}, function (res) { | |
res.on('data', buffs.push.bind(buffs)) | |
res.on('end', () => { | |
const buff = Buffer.concat(buffs) | |
const data = JSON.parse(buff) | |
if (!data.data.length) { | |
return | |
} | |
let earliest | |
data.data.forEach(result => { | |
if (earliest == null || result.started_at < earliest) { | |
earliest = result.started_at | |
} | |
if (result.result !== "pass") { | |
console.log(formatLink(result)) | |
} | |
}) | |
next(earliest) | |
}) | |
}) | |
} | |
next() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment