fix deprecations

This commit is contained in:
Tony Brix 2021-04-05 00:34:59 -05:00
parent daf1eb8f43
commit a1b4ceed1d
14 changed files with 101 additions and 101 deletions

View File

@ -154,11 +154,11 @@ test('apply - replace', function (t) {
// plain
res = Change.apply(single, { cn: ['old'] })
t.deepEqual(res.cn, ['new'])
t.same(res.cn, ['new'])
// multiple
res = Change.apply(single, { cn: ['old', 'also'] })
t.deepEqual(res.cn, ['new'])
t.same(res.cn, ['new'])
// empty
res = Change.apply(empty, { cn: ['existing'] })
@ -167,7 +167,7 @@ test('apply - replace', function (t) {
// absent
res = Change.apply(single, { dn: ['otherjunk'] })
t.deepEqual(res.cn, ['new'])
t.same(res.cn, ['new'])
// scalar formatting "success"
res = Change.apply(single, { cn: 'old' }, true)
@ -175,7 +175,7 @@ test('apply - replace', function (t) {
// scalar formatting "failure"
res = Change.apply(twin, { cn: 'old' }, true)
t.deepEqual(res.cn, ['new', 'two'])
t.same(res.cn, ['new', 'two'])
t.end()
})
@ -192,15 +192,15 @@ test('apply - add', function (t) {
// plain
res = Change.apply(single, { cn: ['old'] })
t.deepEqual(res.cn, ['old', 'new'])
t.same(res.cn, ['old', 'new'])
// multiple
res = Change.apply(single, { cn: ['old', 'also'] })
t.deepEqual(res.cn, ['old', 'also', 'new'])
t.same(res.cn, ['old', 'also', 'new'])
// absent
res = Change.apply(single, { dn: ['otherjunk'] })
t.deepEqual(res.cn, ['new'])
t.same(res.cn, ['new'])
// scalar formatting "success"
res = Change.apply(single, { }, true)
@ -208,11 +208,11 @@ test('apply - add', function (t) {
// scalar formatting "failure"
res = Change.apply(single, { cn: 'old' }, true)
t.deepEqual(res.cn, ['old', 'new'])
t.same(res.cn, ['old', 'new'])
// duplicate add
res = Change.apply(single, { cn: 'new' })
t.deepEqual(res.cn, ['new'])
t.same(res.cn, ['new'])
t.end()
})
@ -229,7 +229,7 @@ test('apply - delete', function (t) {
// plain
res = Change.apply(single, { cn: ['old', 'new'] })
t.deepEqual(res.cn, ['new'])
t.same(res.cn, ['new'])
// empty
res = Change.apply(single, { cn: ['old'] })
@ -242,7 +242,7 @@ test('apply - delete', function (t) {
// scalar formatting "failure"
res = Change.apply(single, { cn: ['old', 'several', 'items'] }, true)
t.deepEqual(res.cn, ['several', 'items'])
t.same(res.cn, ['several', 'items'])
// absent
res = Change.apply(single, { dn: ['otherjunk'] })

View File

@ -408,13 +408,13 @@ tap.test('createClient', t => {
// const socketPath = getSock()
// const server = ldap.createServer()
// server.listen(socketPath, () => {})
// t.tearDown(() => {
// t.teardown(() => {
// client.unbind(() => server.close())
// })
// client = ldap.createClient({ socketPath, log: logger })
// t.ok(logger.child)
// t.true(typeof client.log.child === 'function')
// t.ok(typeof client.log.child === 'function')
// })
t.end()
@ -788,7 +788,7 @@ tap.test('search paged', { timeout: 10000 }, function (t) {
t2.end()
})
t2.tearDown(() => {
t2.teardown(() => {
res.removeListener('searchEntry', entryListener)
res.removeListener('page', pageListener)
})
@ -999,7 +999,7 @@ tap.test('search - sssvlv', { timeout: 10000 }, function (t) {
})
res.on('error', (err) => t2.error(err))
res.on('end', function () {
t2.equals(count, 10)
t2.equal(count, 10)
t2.end()
})
})
@ -1041,7 +1041,7 @@ tap.test('search - sssvlv', { timeout: 10000 }, function (t) {
})
res.on('error', (err) => t2.error(err))
res.on('end', function () {
t2.equals(count, 10)
t2.equal(count, 10)
t2.end()
})
})
@ -1523,10 +1523,10 @@ tap.test('connection refused', function (t) {
client.on('connectRefused', () => {})
client.bind('cn=root', 'secret', function (err, res) {
t.true(err)
t.ok(err)
t.type(err, Error)
t.equals(err.code, 'ECONNREFUSED')
t.false(res)
t.equal(err.code, 'ECONNREFUSED')
t.notOk(res)
t.end()
})
})
@ -1551,11 +1551,11 @@ tap.test('connection timeout', function (t) {
}, 2000)
client.bind('cn=root', 'secret', function (err, res) {
t.true(err)
t.ok(err)
t.type(err, Error)
t.equals(err.message, 'connection timeout')
t.equal(err.message, 'connection timeout')
done = true
t.false(res)
t.notOk(res)
t.end()
})
})
@ -1578,9 +1578,9 @@ tap.only('emitError', function (t) {
t.fail(err)
})
client.on('connectTimeout', (err) => {
t.true(err)
t.ok(err)
t.type(err, Error)
t.equals(err.message, 'connection timeout')
t.equal(err.message, 'connection timeout')
clearTimeout(timeout)
t.end()
})
@ -1602,9 +1602,9 @@ tap.only('emitError', function (t) {
}, 2000)
client.on('error', (err) => {
t.true(err)
t.ok(err)
t.type(err, Error)
t.equals(err.message, 'connectTimeout: connection timeout')
t.equal(err.message, 'connectTimeout: connection timeout')
clearTimeout(timeout)
t.end()
})
@ -1623,10 +1623,10 @@ tap.only('emitError', function (t) {
t.fail(err)
})
client.on('connectRefused', (err) => {
t.true(err)
t.ok(err)
t.type(err, Error)
t.equals(err.message, `connect ECONNREFUSED 0.0.0.0:${unusedPortNumber}`)
t.equals(err.code, 'ECONNREFUSED')
t.equal(err.message, `connect ECONNREFUSED 0.0.0.0:${unusedPortNumber}`)
t.equal(err.code, 'ECONNREFUSED')
t.end()
})
@ -1641,10 +1641,10 @@ tap.only('emitError', function (t) {
})
client.on('error', (err) => {
t.true(err)
t.ok(err)
t.type(err, Error)
t.equals(err.message, `connectRefused: connect ECONNREFUSED 0.0.0.0:${unusedPortNumber}`)
t.equals(err.code, 'ECONNREFUSED')
t.equal(err.message, `connectRefused: connect ECONNREFUSED 0.0.0.0:${unusedPortNumber}`)
t.equal(err.code, 'ECONNREFUSED')
t.end()
})

View File

@ -22,7 +22,7 @@ test('new with args', function (t) {
t.equal(c.type, '1.2.840.113556.1.4.319')
t.ok(c.criticality)
t.equal(c.value.size, 1000)
t.is(Buffer.compare(c.value.cookie, Buffer.from([1, 2, 3])), 0)
t.equal(Buffer.compare(c.value.cookie, Buffer.from([1, 2, 3])), 0)
const writer = new BerWriter()
c.toBer(writer)
@ -32,7 +32,7 @@ test('new with args', function (t) {
t.equal(psc.type, '1.2.840.113556.1.4.319')
t.ok(psc.criticality)
t.equal(psc.value.size, 1000)
t.is(Buffer.compare(psc.value.cookie, Buffer.from([1, 2, 3])), 0)
t.equal(Buffer.compare(psc.value.cookie, Buffer.from([1, 2, 3])), 0)
t.end()
})
@ -55,7 +55,7 @@ test('tober', function (t) {
t.equal(c.type, '1.2.840.113556.1.4.319')
t.ok(c.criticality)
t.equal(c.value.size, 20)
t.is(Buffer.compare(c.value.cookie, Buffer.alloc(0)), 0)
t.equal(Buffer.compare(c.value.cookie, Buffer.alloc(0)), 0)
t.end()
})

View File

@ -171,15 +171,15 @@ test('format persists across clone', function (t) {
const OUT = 'UID="user", CN=foo+SN=bar, DC=test, DC=com'
_dn.setFormat({ keepQuote: true, upperName: true })
const clone = _dn.clone()
t.equals(_dn.toString(), OUT)
t.equals(clone.toString(), OUT)
t.equal(_dn.toString(), OUT)
t.equal(clone.toString(), OUT)
t.end()
})
test('initialization', function (t) {
const dn1 = new dn.DN()
t.ok(dn1)
t.equals(dn1.toString(), '')
t.equal(dn1.toString(), '')
t.ok(dn1.isEmpty(), 'DN with no initializer defaults to null DN')
const data = [
@ -188,7 +188,7 @@ test('initialization', function (t) {
]
const dn2 = new dn.DN(data)
t.ok(dn2)
t.equals(dn2.toString(), 'foo=bar, o=base')
t.equal(dn2.toString(), 'foo=bar, o=base')
t.ok(!dn2.isEmpty())
t.end()

View File

@ -14,7 +14,7 @@ function search (t, options, callback) {
found = true
})
res.on('end', function () {
t.true(found)
t.ok(found)
if (callback) return callback()
return t.end()
})

View File

@ -8,40 +8,40 @@ test('comp > (ref in upper window) => true', async t => {
const ref = Math.floor(MAX_MSGID / 2) + 10
const comp = ref + 10
const result = geWindow(ref, comp)
t.is(result, true)
t.equal(result, true)
})
test('comp < (ref in upper window) => false', async t => {
const ref = Math.floor(MAX_MSGID / 2) + 10
const comp = ref - 5
const result = geWindow(ref, comp)
t.is(result, false)
t.equal(result, false)
})
test('comp > (ref in lower window) => true', async t => {
const ref = Math.floor(MAX_MSGID / 2) - 10
const comp = ref + 20
const result = geWindow(ref, comp)
t.is(result, true)
t.equal(result, true)
})
test('comp < (ref in lower window) => false', async t => {
const ref = Math.floor(MAX_MSGID / 2) - 10
const comp = ref - 5
const result = geWindow(ref, comp)
t.is(result, false)
t.equal(result, false)
})
test('(max === MAX_MSGID) && (comp > ref) => true', async t => {
const ref = MAX_MSGID - Math.floor(MAX_MSGID / 2)
const comp = ref + 1
const result = geWindow(ref, comp)
t.is(result, true)
t.equal(result, true)
})
test('(max === MAX_MSGID) && (comp < ref) => false', async t => {
const ref = MAX_MSGID - Math.floor(MAX_MSGID / 2)
const comp = ref - 1
const result = geWindow(ref, comp)
t.is(result, false)
t.equal(result, false)
})

View File

@ -7,15 +7,15 @@ const idGeneratorFactory = require('../../../../lib/client/message-tracker/id-ge
test('starts at 0', async t => {
const nextID = idGeneratorFactory()
const currentID = nextID()
t.is(currentID, 1)
t.equal(currentID, 1)
})
test('handles wrapping around', async t => {
const nextID = idGeneratorFactory(MAX_MSGID - 2)
let currentID = nextID()
t.is(currentID, MAX_MSGID - 1)
t.equal(currentID, MAX_MSGID - 1)
currentID = nextID()
t.is(currentID, 1)
t.equal(currentID, 1)
})

View File

@ -76,13 +76,13 @@ tap.test('options', t => {
tap.test('.pending', t => {
t.test('returns 0 for no messages', async t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
t.is(tracker.pending, 0)
t.equal(tracker.pending, 0)
})
t.test('returns 1 for 1 message', async t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
tracker.track({}, () => {})
t.is(tracker.pending, 1)
t.equal(tracker.pending, 1)
})
t.end()
@ -92,14 +92,14 @@ tap.test('#abandon', t => {
t.test('returns false if message does not exist', async t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
const result = tracker.abandon(1)
t.is(result, false)
t.equal(result, false)
})
t.test('returns true if message is abandoned', async t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
tracker.track({}, {})
const result = tracker.abandon(1)
t.is(result, true)
t.equal(result, true)
})
t.end()
@ -110,7 +110,7 @@ tap.test('#fetch', t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
tracker.track({}, handler)
const fetched = tracker.fetch(1)
t.is(fetched, handler)
t.equal(fetched, handler)
function handler () {}
})
@ -121,7 +121,7 @@ tap.test('#fetch', t => {
tracker.track({ abandon: 'message' }, () => {})
tracker.abandon(1)
const fetched = tracker.fetch(1)
t.is(fetched, handler)
t.equal(fetched, handler)
function handler () {}
})
@ -129,7 +129,7 @@ tap.test('#fetch', t => {
t.test('returns null when message does not exist', async t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
const fetched = tracker.fetch(1)
t.is(fetched, null)
t.equal(fetched, null)
})
t.end()
@ -146,13 +146,13 @@ tap.test('#purge', t => {
function cb (msgID, handler) {
if (count === 0) {
t.is(msgID, 1)
t.is(handler, handler1)
t.equal(msgID, 1)
t.equal(handler, handler1)
count += 1
return
}
t.is(msgID, 2)
t.is(handler, handler2)
t.equal(msgID, 2)
t.equal(handler, handler2)
}
function handler1 () {}
@ -167,7 +167,7 @@ tap.test('#remove', t => {
const tracker = messageTrackerFactory({ id: 'foo', parser: {} })
tracker.track({}, () => {})
tracker.remove(1)
t.is(tracker.pending, 0)
t.equal(tracker.pending, 0)
})
// Not a great test. It exercises the desired code path, but we probably
@ -178,7 +178,7 @@ tap.test('#remove', t => {
tracker.track({ abandon: 'message' }, () => {})
tracker.abandon(1)
tracker.remove(1)
t.is(tracker.pending, 1)
t.equal(tracker.pending, 1)
})
t.end()
@ -190,9 +190,9 @@ tap.test('#track', t => {
const msg = {}
tracker.track(msg, handler)
t.deepEqual(msg, { messageID: 1 })
t.same(msg, { messageID: 1 })
const cb = tracker.fetch(1)
t.is(cb, handler)
t.equal(cb, handler)
function handler () {}
})

View File

@ -10,11 +10,11 @@ test('clears queue if only one message present', async t => {
abandoned.set(1, { age: 2, cb })
purgeAbandoned(2, abandoned)
t.is(abandoned.size, 0)
t.equal(abandoned.size, 0)
function cb (err) {
t.is(err.name, 'AbandonedError')
t.is(err.message, 'client request abandoned')
t.equal(err.name, 'AbandonedError')
t.equal(err.message, 'client request abandoned')
}
})
@ -25,11 +25,11 @@ test('clears queue if multiple messages present', async t => {
abandoned.set(2, { age: 3, cb })
purgeAbandoned(4, abandoned)
t.is(abandoned.size, 0)
t.equal(abandoned.size, 0)
function cb (err) {
t.is(err.name, 'AbandonedError')
t.is(err.message, 'client request abandoned')
t.equal(err.name, 'AbandonedError')
t.equal(err.message, 'client request abandoned')
}
})
@ -42,11 +42,11 @@ test('message id has wrappred around', async t => {
// that is triggering the purge was the "first" message in the new sequence
// of message identifiers.
purgeAbandoned(1, abandoned)
t.is(abandoned.size, 0)
t.equal(abandoned.size, 0)
function cb (err) {
t.is(err.name, 'AbandonedError')
t.is(err.message, 'client request abandoned')
t.equal(err.name, 'AbandonedError')
t.equal(err.message, 'client request abandoned')
}
})
@ -56,7 +56,7 @@ test('does not clear if window not met', async t => {
abandoned.set(1, { age: 2, cb })
purgeAbandoned(1, abandoned)
t.is(abandoned.size, 1)
t.equal(abandoned.size, 1)
function cb () {
t.fail('should not be invoked')

View File

@ -6,13 +6,13 @@ const enqueue = require('../../../../lib/client/request-queue/enqueue')
test('rejects new requests if size is exceeded', async t => {
const q = { _queue: { length: 5 }, size: 5 }
const result = enqueue.call(q, 'foo', 'bar', {}, {})
t.false(result)
t.notOk(result)
})
test('rejects new requests if queue is frozen', async t => {
const q = { _queue: { length: 0 }, size: 5, _frozen: true }
const result = enqueue.call(q, 'foo', 'bar', {}, {})
t.false(result)
t.notOk(result)
})
test('adds a request and returns if no timeout', async t => {
@ -20,7 +20,7 @@ test('adds a request and returns if no timeout', async t => {
_queue: {
length: 0,
add (obj) {
t.deepEqual(obj, {
t.same(obj, {
message: 'foo',
expect: 'bar',
emitter: 'baz',
@ -32,7 +32,7 @@ test('adds a request and returns if no timeout', async t => {
timeout: 0
}
const result = enqueue.call(q, 'foo', 'bar', 'baz', 'bif')
t.true(result)
t.ok(result)
})
test('adds a request and returns timer not set', async t => {
@ -40,7 +40,7 @@ test('adds a request and returns timer not set', async t => {
_queue: {
length: 0,
add (obj) {
t.deepEqual(obj, {
t.same(obj, {
message: 'foo',
expect: 'bar',
emitter: 'baz',
@ -53,7 +53,7 @@ test('adds a request and returns timer not set', async t => {
_timer: null
}
const result = enqueue.call(q, 'foo', 'bar', 'baz', 'bif')
t.true(result)
t.ok(result)
})
test('adds a request, returns true, and clears queue', t => {
@ -63,7 +63,7 @@ test('adds a request, returns true, and clears queue', t => {
_queue: {
length: 0,
add (obj) {
t.deepEqual(obj, {
t.same(obj, {
message: 'foo',
expect: 'bar',
emitter: 'baz',
@ -78,5 +78,5 @@ test('adds a request, returns true, and clears queue', t => {
purge () { t.pass() }
}
const result = enqueue.call(q, 'foo', 'bar', 'baz', 'bif')
t.true(result)
t.ok(result)
})

View File

@ -17,7 +17,7 @@ test('clears timer', async t => {
}
}
flush.call(q)
t.is(q._timer, null)
t.equal(q._timer, null)
})
test('invokes callback with parameters', async t => {
@ -40,12 +40,12 @@ test('invokes callback with parameters', async t => {
}
}
flush.call(q, (message, expect, emitter, cb) => {
t.is(message, 'foo')
t.is(expect, 'bar')
t.is(emitter, 'baz')
t.is(cb, theCB)
t.equal(message, 'foo')
t.equal(expect, 'bar')
t.equal(emitter, 'baz')
t.equal(cb, theCB)
})
t.is(q._timer, null)
t.equal(q._timer, null)
function theCB () {}
})

View File

@ -9,8 +9,8 @@ test('flushes the queue with timeout errors', async t => {
flush (func) {
func('a', 'b', 'c', (err) => {
t.ok(err)
t.is(err.name, 'TimeoutError')
t.is(err.message, 'request queue timeout')
t.equal(err.name, 'TimeoutError')
t.equal(err.message, 'request queue timeout')
})
}
}

View File

@ -17,9 +17,9 @@ test('new with args', function (t) {
t.ok(req)
t.equal(req.requestName, '1.2.3.4')
t.equal(req.requestValue, 'test')
t.is(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(req.value, 'test')
t.is(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.end()
})
@ -31,9 +31,9 @@ test('new with buffer args', function (t) {
t.ok(req)
t.equal(req.requestName, '1.2.3.4')
t.equal(req.requestValue, req.requestValueBuffer)
t.is(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(req.value, req.valueBuffer)
t.is(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.end()
})
@ -46,9 +46,9 @@ test('new no args set args', function (t) {
req.value = 'test'
t.equal(req.requestValue, 'test')
t.is(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(req.value, 'test')
t.is(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.end()
})
@ -62,9 +62,9 @@ test('new no args set args buffer', function (t) {
req.value = Buffer.from('test', 'utf8')
t.equal(req.requestValue, req.requestValueBuffer)
t.is(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(req.value, req.valueBuffer)
t.is(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.end()
})
@ -78,9 +78,9 @@ test('parse', function (t) {
t.ok(req._parse(new BerReader(ber.buffer)))
t.equal(req.requestName, '1.2.3.4')
t.equal(req.requestValue, 'test')
t.is(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.requestValueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(req.value, 'test')
t.is(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.equal(Buffer.compare(req.valueBuffer, Buffer.from('test', 'utf8')), 0)
t.end()
})

View File

@ -75,7 +75,7 @@ tap.test('listen on static port', function (t) {
server.listen(SERVER_PORT, '127.0.0.1', function () {
const addr = server.address()
t.equal(addr.port, parseInt(SERVER_PORT, 10))
t.equals(server.url, `ldap://127.0.0.1:${SERVER_PORT}`)
t.equal(server.url, `ldap://127.0.0.1:${SERVER_PORT}`)
server.close(() => t.end())
})
})