From 13428540a01d07b898b51913eedda8aa218a97a0 Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Thu, 17 Sep 2015 15:35:06 +0500 Subject: [PATCH] use ifError --- test/test-arguments.js | 4 ++-- test/test-gzip.js | 4 ++-- test/test-headers.js | 10 +++++----- test/test-helpers.js | 2 +- test/test-http.js | 12 ++++++------ test/test-https.js | 10 +++++----- test/test-json.js | 4 ++-- test/test-post.js | 24 ++++++++++++------------ test/test-redirects.js | 8 ++++---- test/test-unix-socket.js | 4 ++-- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/test/test-arguments.js b/test/test-arguments.js index 82298a9e6..d45ee6bb5 100644 --- a/test/test-arguments.js +++ b/test/test-arguments.js @@ -37,7 +37,7 @@ test('arguments - url argument is required', function (t) { test('arguments - accepts url.parse object as first argument', function (t) { got({hostname: s.host, port: s.port, path: '/test'}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, '/test'); t.end(); }); @@ -45,7 +45,7 @@ test('arguments - accepts url.parse object as first argument', function (t) { test('arguments - overrides querystring from opts', function (t) { got(s.url + '/?test=doge', {query: {test: 'wow'}}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, '/?test=wow'); t.end(); }); diff --git a/test/test-gzip.js b/test/test-gzip.js index b53376f00..986ddd75c 100644 --- a/test/test-gzip.js +++ b/test/test-gzip.js @@ -30,7 +30,7 @@ test.before('gzip - setup', function (t) { test('gzip - ungzip content', function (t) { got(s.url, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, testContent); t.end(); }); @@ -48,7 +48,7 @@ test('gzip - ungzip error', function (t) { test('gzip - preserve headers property', function (t) { got(s.url, function (err, data, res) { - t.error(err); + t.ifError(err); t.ok(res.headers); t.end(); }); diff --git a/test/test-headers.js b/test/test-headers.js index bba9c51e2..02529a73b 100644 --- a/test/test-headers.js +++ b/test/test-headers.js @@ -16,7 +16,7 @@ test.before('headers - setup', function (t) { test('headers - send user-agent header by default', function (t) { got(s.url, function (err, data) { - t.error(err); + t.ifError(err); var headers = JSON.parse(data); @@ -27,7 +27,7 @@ test('headers - send user-agent header by default', function (t) { test('headers - send accept-encoding header by default', function (t) { got(s.url, function (err, data) { - t.error(err); + t.ifError(err); var headers = JSON.parse(data); @@ -38,7 +38,7 @@ test('headers - send accept-encoding header by default', function (t) { test('headers - send accept header with json option', function (t) { got(s.url, {json: true}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers.accept, 'application/json'); t.end(); }); @@ -46,7 +46,7 @@ test('headers - send accept header with json option', function (t) { test('headers - send host header by default', function (t) { got(s.url, function (err, data) { - t.error(err); + t.ifError(err); var headers = JSON.parse(data); @@ -57,7 +57,7 @@ test('headers - send host header by default', function (t) { test('headers - transform headers names to lowercase', function (t) { got(s.url, {headers: {'USER-AGENT': 'test'}}, function (err, data) { - t.error(err); + t.ifError(err); var headers = JSON.parse(data); diff --git a/test/test-helpers.js b/test/test-helpers.js index 9d168083d..2bca8ae36 100644 --- a/test/test-helpers.js +++ b/test/test-helpers.js @@ -21,7 +21,7 @@ test.before('helpers - setup', function (t) { test('helpers - callback mode', function (t) { got.get(s.url, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'ok'); t.end(); }); diff --git a/test/test-http.js b/test/test-http.js index 4d04309a1..a0f054b97 100644 --- a/test/test-http.js +++ b/test/test-http.js @@ -31,7 +31,7 @@ test.before('http - setup', function (t) { test('http - callback mode', function (t) { got(s.url, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'ok'); t.end(); }); @@ -39,7 +39,7 @@ test('http - callback mode', function (t) { test('http - protocol-less URLs', function (t) { got(s.url.replace(/^http:\/\//, ''), function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'ok'); t.end(); }); @@ -47,7 +47,7 @@ test('http - protocol-less URLs', function (t) { test('http - empty response', function (t) { got(s.url + '/empty', function (err, data) { - t.error(err); + t.ifError(err); t.is(data, ''); t.end(); }); @@ -64,7 +64,7 @@ test('http - error with code', function (t) { test('http - buffer on encoding === null', function (t) { got(s.url, {encoding: null}, function (err, data) { - t.error(err); + t.ifError(err); t.ok(Buffer.isBuffer(data)); t.end(); }); @@ -81,12 +81,12 @@ test('http - query option', function (t) { t.plan(4); got(s.url, {query: {recent: true}}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'recent'); }); got(s.url, {query: 'recent=true'}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'recent'); }); }); diff --git a/test/test-https.js b/test/test-https.js index f2c0cc97f..63f819761 100644 --- a/test/test-https.js +++ b/test/test-https.js @@ -15,7 +15,7 @@ test.before('https - create root pem', function (t) { days: 1, selfSigned: true }, function (err, keys) { - t.error(err); + t.ifError(err); caRootKey = keys.serviceKey; caRootCert = keys.certificate; t.end(); @@ -35,7 +35,7 @@ test.before('https - create pem', function (t) { organizationUnit: '', commonName: 'sindresorhus.com' }, function (err, keys) { - t.error(err); + t.ifError(err); key = keys.clientKey; cert = keys.certificate; t.end(); @@ -59,7 +59,7 @@ test.before('https - setup', function (t) { test('https - redirects from http to https works', function (t) { got('http://github.com', function (err, data) { - t.error(err); + t.ifError(err); t.ok(data); t.end(); }); @@ -69,7 +69,7 @@ test('https - make request to https server', function (t) { got('https://google.com', { strictSSL: true }, function (err, data) { - t.error(err); + t.ifError(err); t.ok(data); t.end(); }); @@ -81,7 +81,7 @@ test('https - make request to https server with ca', function (t) { ca: caRootCert, headers: {host: 'sindresorhus.com'} }, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'ok'); t.end(); }); diff --git a/test/test-json.js b/test/test-json.js index 94ce1e81d..5ee3c268d 100644 --- a/test/test-json.js +++ b/test/test-json.js @@ -35,7 +35,7 @@ test.before('json - setup', function (t) { test('json - json option should parse response', function (t) { got(s.url, {json: true}, function (err, json) { - t.error(err); + t.ifError(err); t.same(json, {data: 'dog'}); t.end(); }); @@ -43,7 +43,7 @@ test('json - json option should parse response', function (t) { test('json - json option should not parse responses without a body', function (t) { got(s.url + '/204', {json: true}, function (err) { - t.error(err); + t.ifError(err); t.end(); }); }); diff --git a/test/test-post.js b/test/test-post.js index c3dfca273..c2b3d9d7c 100644 --- a/test/test-post.js +++ b/test/test-post.js @@ -39,7 +39,7 @@ test.before('post - setup', function (t) { // }); // // got.get(s.url + '/method', {body: stream}, function (err, data, res) { -// t.error(err); +// t.ifError(err); // t.is(res.headers.method, 'GET'); // }); // }); @@ -48,24 +48,24 @@ test('post - send data from options with post request', function (t) { t.plan(6); got(s.url, {body: 'wow'}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'wow'); }); got(s.url, {body: new Buffer('wow')}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'wow'); }); got(s.url, {body: intoStream(['wow'])}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'wow'); }); }); test('post - works with empty post response', function (t) { got(s.url + '/empty', {body: 'wow'}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, ''); t.end(); }); @@ -75,27 +75,27 @@ test('post - post have content-length header to string', function (t) { t.plan(10); got(s.url + '/headers', {body: 'wow', json: true}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers['content-length'], '3'); }); got(s.url + '/headers', {body: new Buffer('wow'), json: true}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers['content-length'], '3'); }); got(s.url + '/headers', {body: intoStream(['wow']), json: true}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers['content-length'], undefined); }); got(s.url + '/headers', {body: 'wow', json: true, headers: {'content-length': '10'}}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers['content-length'], '10'); }); got(s.url + '/headers', {body: '3\r\nwow\r\n0\r\n', json: true, headers: {'transfer-encoding': 'chunked'}}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers['content-length'], undefined); }); }); @@ -104,12 +104,12 @@ test('post - works with plain object in body', function (t) { t.plan(4); got(s.url, {body: {such: 'wow'}}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'such=wow'); }); got(s.url + '/headers', {headers: {'content-type': 'doge'}, body: {such: 'wow'}, json: true}, function (err, headers) { - t.error(err); + t.ifError(err); t.is(headers['content-type'], 'doge'); }); }); diff --git a/test/test-redirects.js b/test/test-redirects.js index 74a797d7e..ece8d3a2f 100644 --- a/test/test-redirects.js +++ b/test/test-redirects.js @@ -44,7 +44,7 @@ test.before('redirects - setup', function (t) { test('redirects - follows redirect', function (t) { got(s.url + '/finite', function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'reached'); t.end(); }); @@ -52,7 +52,7 @@ test('redirects - follows redirect', function (t) { test('redirects - follows relative redirect', function (t) { got(s.url + '/relative', function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'reached'); t.end(); }); @@ -68,7 +68,7 @@ test('redirects - throws on endless redirect', function (t) { test('redirects - query in options are not breaking redirects', function (t) { got(s.url + '/relativeQuery', {query: 'bang'}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'reached'); t.end(); }); @@ -76,7 +76,7 @@ test('redirects - query in options are not breaking redirects', function (t) { test('redirects - hostname+path in options are not breaking redirects', function (t) { got(s.url + '/relative', {hostname: s.host, path: '/relative'}, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'reached'); t.end(); }); diff --git a/test/test-unix-socket.js b/test/test-unix-socket.js index 8139243b8..f58693c53 100644 --- a/test/test-unix-socket.js +++ b/test/test-unix-socket.js @@ -23,7 +23,7 @@ test('unix-socket - request via unix socket', function (t) { var url = format('http://unix:%s:%s', socketPath, '/'); got(url, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'ok'); t.end(); }); @@ -33,7 +33,7 @@ test('unix-socket - protocol-less request', function (t) { var url = format('unix:%s:%s', socketPath, '/'); got(url, function (err, data) { - t.error(err); + t.ifError(err); t.is(data, 'ok'); t.end(); });