| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/redis-url/test/ |
Upload File : |
var test = require("tape")
test("redis-url", function (t) {
t.plan(30)
// Parse a simple URL
var parts = require('..').parse('redis://localhost:6379')
t.equal(parts.password, undefined)
t.equal(parts.host, 'localhost:6379')
t.equal(parts.hostname, 'localhost')
t.equal(parts.port, '6379')
t.equal(parts.path, '')
t.equal(parts.database, '0')
t.deepEqual(parts.query, {})
// Parse a more complex URL
parts = require('..').parse('redis://:secrets@example.com:1234/9?foo=bar&baz=qux')
t.equal(parts.password, 'secrets')
t.equal(parts.host, 'example.com:1234')
t.equal(parts.hostname, 'example.com')
t.equal(parts.port, '1234')
t.equal(parts.path, '9')
t.equal(parts.database, '9')
t.deepEqual(parts.query, {foo: 'bar', baz: 'qux'})
// Simple url, no protocol submitted
parts = require('..').parse('localhost:6379')
t.equal(parts.password, undefined)
t.equal(parts.host, 'localhost:6379')
t.equal(parts.hostname, 'localhost')
t.equal(parts.port, '6379')
t.equal(parts.path, '')
t.equal(parts.database, '0')
t.deepEqual(parts.query, {})
// More complex one
parts = require('..').parse(':pass@example.com:1234/9?foo=bar&baz=qux')
t.equal(parts.password, 'pass')
t.equal(parts.host, 'example.com:1234')
t.equal(parts.hostname, 'example.com')
t.equal(parts.port, '1234')
t.equal(parts.path, '9')
t.equal(parts.database, '9')
t.deepEqual(parts.query, {foo: 'bar', baz: 'qux'})
// Connect to default URL
var redis = require('..').createClient()
redis.set('foo', 'bar')
redis.get('foo', function(err, res) {
if (err) throw errr
t.equal(res, 'bar', "foo should equal bar")
redis.quit()
})
// Connect to specified URL
var redis2 = require('..').createClient('redis://localhost:6379')
redis2.set('food', 'bar')
redis2.get('food', function(err, res) {
if (err) throw errr
t.equal(res, 'bar', "food should equal bar")
redis2.quit()
})
})