Browse Source

Speed up tests

http2
Vsevolod Strukchinsky 9 years ago
parent
commit
9b9d359138
  1. 2
      test/error.js
  2. 2
      test/helpers.js
  3. 2
      test/http.js
  4. 12
      test/retry.js
  5. 4
      test/stream.js

2
test/error.js

@ -24,7 +24,7 @@ test('error - error message', t => {
});
test('error - dns error message', t => {
got('.com', err => {
got('.com', {retries: 0}, err => {
t.ok(err);
t.regexTest(/getaddrinfo ENOTFOUND/, err.message);
t.is(err.host, '.com');

2
test/helpers.js

@ -36,7 +36,7 @@ test('helpers - promise mode', t => {
t.is(err.response.body, 'not found');
});
got.get('.com').catch(err => {
got.get('.com', {retries: 0}).catch(err => {
t.ok(err);
});
});

2
test/http.js

@ -69,7 +69,7 @@ test('http - buffer on encoding === null', t => {
});
test('http - timeout option', t => {
got(`${s.url}/404`, {timeout: 1, retries: 1}, err => {
got(`${s.url}/404`, {timeout: 1, retries: 0}, err => {
t.is(err.code, 'ETIMEDOUT');
t.end();
});

12
test/retry.js

@ -13,6 +13,11 @@ s.on('/knock-twice', (req, res) => {
}
});
let trys = 0;
s.on('/try-me', () => {
trys++;
});
test.before('retry - setup', t => {
s.listen(s.port, () => t.end());
});
@ -25,6 +30,13 @@ test('retry - timeout errors', t => {
});
});
test('retry - can be disabled with option', t => {
got(`${s.url}/try-me`, {timeout: 1000, retries: 0}, () => {
t.is(trys, 1);
t.end();
});
});
test.after('error - cleanup', t => {
s.close();
t.end();

4
test/stream.js

@ -98,7 +98,7 @@ test('stream - response event', t => {
});
test('stream - error event', t => {
got.stream(`${s.url}/error`)
got.stream(`${s.url}/error`, {retries: 0})
.on('response', () => {
t.fail('response event should not be emitted');
})
@ -111,7 +111,7 @@ test('stream - error event', t => {
});
test('stream - error event', t => {
got.stream('.com')
got.stream('.com', {retries: 0})
.on('response', () => {
t.fail('response event should not be emitted');
})

Loading…
Cancel
Save