You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-01 16:46:54 +03:00
Standard is not as up to date and still uses a old eslint version. Instead, use the airbnb default with a couple of modifications. All required changes are included.
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const config = require('../lib/config')
|
|
const crypto = require('crypto')
|
|
const helper = require('../helper')
|
|
|
|
const { redis } = config
|
|
|
|
describe('The \'script\' method', () => {
|
|
helper.allTests((ip, args) => {
|
|
const command = 'return 99'
|
|
const commandSha = crypto.createHash('sha1').update(command).digest('hex')
|
|
|
|
describe(`using ${ip}`, () => {
|
|
let client
|
|
|
|
beforeEach(() => {
|
|
client = redis.createClient.apply(null, args)
|
|
return client.flushdb()
|
|
})
|
|
|
|
afterEach(() => {
|
|
client.end(true)
|
|
})
|
|
|
|
it('loads script with client.script(\'load\')', () => {
|
|
return client.script('load', command).then(helper.isString(commandSha))
|
|
})
|
|
|
|
it('allows a loaded script to be evaluated', () => {
|
|
return client.evalsha(commandSha, 0).then(helper.isNumber(99))
|
|
})
|
|
|
|
it('allows a script to be loaded as part of a chained transaction', () => {
|
|
return client.multi().script('load', command).exec(helper.isDeepEqual([commandSha]))
|
|
})
|
|
|
|
it('allows a script to be loaded using a transaction\'s array syntax', () => {
|
|
return client.multi([['script', 'load', command]]).exec(helper.isDeepEqual([commandSha]))
|
|
})
|
|
})
|
|
})
|
|
})
|