-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathmemcached-add.test.js
More file actions
46 lines (38 loc) · 1.1 KB
/
Copy pathmemcached-add.test.js
File metadata and controls
46 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
/**
* Test dependencies
*/
var assert = require('assert')
, fs = require('fs')
, common = require('./common')
, Memcached = require('../')
, should = require('should')
;
global.testnumbers = global.testnumbers || +(Math.random(10) * 1000000).toFixed();
/**
* Expresso test suite for all `add` related
* memcached commands
*/
describe('Memcached ADD', function () {
/**
* Make sure that adding a key which already exists returns an error.
*/
it('fail to add an already existing key', function (done) {
var memcached = new Memcached(common.servers.single)
, message = common.alphabet(256)
, testnr = ++global.testnumbers
, callbacks = 0;
memcached.set('test:' + testnr, message, 1000, function (error, ok) {
++callbacks;
assert.ok(!error);
ok.should.be.true;
memcached.add('test:' + testnr, message, 1000, function (error, answer) {
++callbacks;
assert.ok(error);
memcached.end(); // close connections
assert.equal(callbacks, 2);
done();
});
});
});
});