Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Should maintain 2000ms between search requests', async function () {
const octokit = new Octokit({
throttle: {
search: new Bottleneck.Group({ minTime: 50 }),
onAbuseLimit: () => 1,
onRateLimit: () => 1
}
})
const req1 = octokit.request('GET /search/route1', {
request: {
responses: [{ status: 201, headers: {}, data: {} }]
}
})
const req2 = octokit.request('GET /route2', {
request: {
responses: [{ status: 202, headers: {}, data: {} }]
}
})
const req3 = octokit.request('GET /search/route3', {
it('Should optimize throughput rather than maintain ordering', async function () {
const octokit = new Octokit({
throttle: {
write: new Bottleneck.Group({ minTime: 50 }),
notifications: new Bottleneck.Group({ minTime: 150 }),
onAbuseLimit: () => 1,
onRateLimit: () => 1
}
})
const req1 = octokit.request('POST /orgs/abc/invitations', {
request: {
responses: [{ status: 200, headers: {}, data: {} }]
}
})
const req2 = octokit.request('GET /route2', {
request: {
responses: [{ status: 200, headers: {}, data: {} }]
}
})
const req3 = octokit.request('GET /route3', {
it('Should retry \'rate-limit\' and succeed', async function () {
let eventCount = 0
const octokit = new Octokit({
throttle: {
write: new Bottleneck.Group({ minTime: 50 }),
onRateLimit: (retryAfter, options) => {
expect(options).to.include({ method: 'POST', url: '/graphql' })
expect(options.request.retryCount).to.equal(eventCount)
expect(retryAfter).to.equal(0)
eventCount++
return true
},
onAbuseLimit: () => 1
}
})
const res = await octokit.request('POST /graphql', {
request: {
responses: [
{ status: 200, headers: { 'x-ratelimit-remaining': '0', 'x-ratelimit-reset': '123' }, data: { errors: [{ type: 'RATE_LIMITED' }] } },
{ status: 200, headers: {}, data: { message: 'Yay!' } }
it('Should maintain 1000ms between mutating or GraphQL requests', async function () {
const octokit = new Octokit({
throttle: {
write: new Bottleneck.Group({ minTime: 50 }),
onAbuseLimit: () => 1,
onRateLimit: () => 1
}
})
const req1 = octokit.request('POST /route1', {
request: {
responses: [{ status: 201, headers: {}, data: {} }]
}
})
const req2 = octokit.request('GET /route2', {
request: {
responses: [{ status: 202, headers: {}, data: {} }]
}
})
const req3 = octokit.request('POST /route3', {