Comparing version 2.9.0 to 2.10.0
{ | ||
"name": "rqlite-fp", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "rqlite", |
@@ -0,1 +1,2 @@ | ||
const http = require('http'); | ||
const righto = require('righto'); | ||
@@ -20,2 +21,39 @@ const tape = require('tape'); | ||
test('connect with no callback', function * (t) { | ||
t.plan(1); | ||
try { | ||
connect('http://localhost:4001'); | ||
} catch (error) { | ||
t.equal(error.message, 'rqlite.connect requires a callback'); | ||
} | ||
}); | ||
test('connect to something not rqlite - json', function * (t) { | ||
t.plan(1); | ||
const server = http.createServer((request, response) => { | ||
response.writeHead(200, { 'Content-Type': 'application/json' }); | ||
response.end('{"a":1}'); | ||
}).listen(4002); | ||
connect('http://localhost:4002', (error, result) => { | ||
t.equal(error.message, 'url does not look like an rqlite database'); | ||
server.close(); | ||
}); | ||
}); | ||
test('connect to something not rqlite - not json', function * (t) { | ||
t.plan(1); | ||
const server = http.createServer((request, response) => { | ||
response.end('im not rqlite'); | ||
}).listen(4002); | ||
connect('http://localhost:4002', (error, result) => { | ||
t.equal(error.message, 'The response body could not be JSON.parsed'); | ||
server.close(); | ||
}); | ||
}); | ||
test('connect when not running', function * (t) { | ||
@@ -41,2 +79,26 @@ t.plan(1); | ||
test('connect with retries when not running - with no retires set', function * (t) { | ||
t.plan(3); | ||
const startTime = Date.now(); | ||
connect('http://localhost:4001', { retries: 3 }, function (error) { | ||
const endTime = Date.now(); | ||
t.ok(endTime - startTime > 300, 'Took more than 300ms to fail'); | ||
t.ok(endTime - startTime > 300, 'Took less than 1000ms to fail'); | ||
t.equal(error.message, 'ECONNREFUSED: Could not connect to http://localhost:4001'); | ||
}); | ||
}); | ||
test('connect with retries when not running', function * (t) { | ||
t.plan(3); | ||
const startTime = Date.now(); | ||
connect('http://localhost:4001', { retries: 3, retryDelay: 100 }, function (error) { | ||
const endTime = Date.now(); | ||
t.ok(endTime - startTime > 300, 'Took more than 300ms to fail'); | ||
t.ok(endTime - startTime > 300, 'Took less than 1000ms to fail'); | ||
t.equal(error.message, 'ECONNREFUSED: Could not connect to http://localhost:4001'); | ||
}); | ||
}); | ||
test('connect with retries with onRetry', function * (t) { | ||
@@ -43,0 +105,0 @@ t.plan(1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25540
17
644
2