~ubuntu-branches/ubuntu/jaunty/memcached/jaunty

« back to all changes in this revision

Viewing changes to t/getset.t

  • Committer: Bazaar Package Importer
  • Author(s): Jay Bonci
  • Date: 2007-05-02 11:35:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502113542-qpoxsq28fjb7s9wc
Tags: 1.2.1-1
* New upstream release (Closes: #405054)
* Fix to logfile output so logrotate will work (Closes: #417941)
* Listen in on localhost by default (Closes: #383660)
* Default configuration suggests nobody by default (Closes: #391351)
* Bumped policy version to 3.7.2.2 (No other changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use Test::More tests => 14;
 
5
use FindBin qw($Bin);
 
6
use lib "$Bin/lib";
 
7
use MemcachedTest;
 
8
 
 
9
my $server = new_memcached();
 
10
my $sock = $server->sock;
 
11
 
 
12
# set foo (and should get it)
 
13
print $sock "set foo 0 0 6\r\nfooval\r\n";
 
14
is(scalar <$sock>, "STORED\r\n", "stored foo");
 
15
mem_get_is($sock, "foo", "fooval");
 
16
 
 
17
# add bar (and should get it)
 
18
print $sock "add bar 0 0 6\r\nbarval\r\n";
 
19
is(scalar <$sock>, "STORED\r\n", "stored barval");
 
20
mem_get_is($sock, "bar", "barval");
 
21
 
 
22
# add foo (but shouldn't get new value)
 
23
print $sock "add foo 0 0 5\r\nfoov2\r\n";
 
24
is(scalar <$sock>, "NOT_STORED\r\n", "not stored");
 
25
mem_get_is($sock, "foo", "fooval");
 
26
 
 
27
# replace bar (should work)
 
28
print $sock "replace bar 0 0 6\r\nbarva2\r\n";
 
29
is(scalar <$sock>, "STORED\r\n", "replaced barval 2");
 
30
 
 
31
# replace notexist (shouldn't work)
 
32
print $sock "replace notexist 0 0 6\r\nbarva2\r\n";
 
33
is(scalar <$sock>, "NOT_STORED\r\n", "didn't replace notexist");
 
34
 
 
35
# delete foo.
 
36
print $sock "delete foo\r\n";
 
37
is(scalar <$sock>, "DELETED\r\n", "deleted foo");
 
38
 
 
39
# delete foo again.  not found this time.
 
40
print $sock "delete foo\r\n";
 
41
is(scalar <$sock>, "NOT_FOUND\r\n", "deleted foo, but not found");
 
42
 
 
43
# pipeling is okay
 
44
print $sock "set foo 0 0 6\r\nfooval\r\ndelete foo\r\nset foo 0 0 6\r\nfooval\r\ndelete foo\r\n";
 
45
is(scalar <$sock>, "STORED\r\n",  "pipeline set");
 
46
is(scalar <$sock>, "DELETED\r\n", "pipeline delete");
 
47
is(scalar <$sock>, "STORED\r\n",  "pipeline set");
 
48
is(scalar <$sock>, "DELETED\r\n", "pipeline delete");
 
49
 
 
50
 
 
51