mirror of https://github.com/lukechilds/got.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
752 B
41 lines
752 B
import test from 'ava';
|
|
import got from '../';
|
|
import {createServer} from './_server';
|
|
|
|
const s = createServer();
|
|
|
|
s.on('/long', () => {});
|
|
|
|
let knocks = 0;
|
|
s.on('/knock-twice', (req, res) => {
|
|
if (knocks++ === 1) {
|
|
res.end('who`s there?');
|
|
}
|
|
});
|
|
|
|
let trys = 0;
|
|
s.on('/try-me', () => {
|
|
trys++;
|
|
});
|
|
|
|
test.before('retry - setup', t => {
|
|
s.listen(s.port, () => t.end());
|
|
});
|
|
|
|
test('retry - timeout errors', async t => {
|
|
t.is((await got(`${s.url}/knock-twice`, {timeout: 1000})).body, 'who`s there?');
|
|
});
|
|
|
|
test('retry - can be disabled with option', async t => {
|
|
try {
|
|
await got(`${s.url}/try-me`, {timeout: 1000, retries: 0});
|
|
} catch (err) {
|
|
t.ok(err);
|
|
}
|
|
t.is(trys, 1);
|
|
});
|
|
|
|
test.after('error - cleanup', t => {
|
|
s.close();
|
|
t.end();
|
|
});
|
|
|