You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +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.
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const assert = require('assert')
|
|
const config = require('../lib/config')
|
|
const helper = require('../helper')
|
|
|
|
const { redis } = config
|
|
|
|
describe('The \'watch\' method', () => {
|
|
helper.allTests((ip, args) => {
|
|
const watched = 'foobar'
|
|
|
|
describe(`using ${ip}`, () => {
|
|
let client
|
|
|
|
beforeEach(() => {
|
|
client = redis.createClient.apply(null, args)
|
|
return client.flushdb()
|
|
})
|
|
|
|
afterEach(() => {
|
|
client.end(true)
|
|
})
|
|
|
|
it('does not execute transaction if watched key was modified prior to execution', () => {
|
|
client.watch(watched)
|
|
client.incr(watched)
|
|
const multi = client.multi()
|
|
multi.incr(watched)
|
|
return multi.exec().then(helper.isNull())
|
|
})
|
|
|
|
it('successfully modifies other keys independently of transaction', () => {
|
|
client.set('unwatched', 200)
|
|
|
|
client.set(watched, 0)
|
|
client.watch(watched)
|
|
client.incr(watched)
|
|
|
|
return client.multi().incr(watched).exec().then((replies) => {
|
|
assert.strictEqual(replies, null, 'Aborted transaction multi-bulk reply should be null.')
|
|
|
|
return client.get('unwatched').then(helper.isString('200'))
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|