Skip to content

Instantly share code, notes, and snippets.

@grncdr
Created August 1, 2016 12:18
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 grncdr/e020a8fe371fbf6108f4b4bf0b2be944 to your computer and use it in GitHub Desktop.
Save grncdr/e020a8fe371fbf6108f4b4bf0b2be944 to your computer and use it in GitHub Desktop.
Find errors from runscope
#!/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