From 9b9d35913833f136a6543e2fe015f5ff0543d8f1 Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Thu, 15 Oct 2015 10:43:43 +0500 Subject: [PATCH] Speed up tests --- test/error.js | 2 +- test/helpers.js | 2 +- test/http.js | 2 +- test/retry.js | 12 ++++++++++++ test/stream.js | 4 ++-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/test/error.js b/test/error.js index 809791f..7eb5323 100644 --- a/test/error.js +++ b/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'); diff --git a/test/helpers.js b/test/helpers.js index b492601..05d0c2f 100644 --- a/test/helpers.js +++ b/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); }); }); diff --git a/test/http.js b/test/http.js index 056c0d3..d0bda50 100644 --- a/test/http.js +++ b/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(); }); diff --git a/test/retry.js b/test/retry.js index d1e1f61..a8db42a 100644 --- a/test/retry.js +++ b/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(); diff --git a/test/stream.js b/test/stream.js index c81b275..d935f31 100644 --- a/test/stream.js +++ b/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'); })