Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Test add with an already existing key (should return error) #61

Merged
merged 1 commit into from

2 participants

@privman

The test hasn't been run, I don't have mocha installed

@3rd-Eden
Owner

Thanks :)!

@3rd-Eden 3rd-Eden merged commit d1c6386 into 3rd-Eden:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 45 additions and 0 deletions.
  1. +45 −0 tests/memcached-add.test.js
View
45 tests/memcached-add.test.js
@@ -0,0 +1,45 @@
+/**
+ * Test dependencies
+ */
+
+var assert = require('assert')
+ , fs = require('fs')
+ , common = require('./common')
+ , Memcached = require('../');
+
+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();
+
+ });
+ });
+ });
+
+});
Something went wrong with that request. Please try again.