[memcached] bradfitz, r342: move expirations code to use mem_get_is,
...
commits at code.sixapart.com
commits at code.sixapart.com
Mon Sep 4 06:00:52 UTC 2006
move expirations code to use mem_get_is, and start flags test
U trunk/server/test/expirations.t
A trunk/server/test/flags.t
U trunk/server/test/lib/MemcachedTest.pm
Modified: trunk/server/test/expirations.t
===================================================================
--- trunk/server/test/expirations.t 2006-09-04 05:49:01 UTC (rev 341)
+++ trunk/server/test/expirations.t 2006-09-04 06:00:51 UTC (rev 342)
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-use Test::More tests => 5;
+use Test::More tests => 3;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
@@ -9,16 +9,12 @@
my $server = new_memcached();
my $sock = $server->sock;
-print $sock "set foo 123 1 6\r\nfooval\r\n";
+print $sock "set foo 0 1 6\r\nfooval\r\n";
is(scalar <$sock>, "STORED\r\n", "stored foo");
-print $sock "get foo\n";
-is(scalar <$sock>, "VALUE foo 123 6\r\n", "got FOO value");
-is(scalar <$sock>, "fooval\r\n", "got fooval");
-is(scalar <$sock>, "END\r\n", "got END");
+mem_get_is($sock, "foo", "fooval");
sleep(1.2);
-print $sock "get foo\n";
-is(scalar <$sock>, "END\r\n", "got END (no value)");
+mem_get_is($sock, "foo", undef);
@@ -26,3 +22,4 @@
+
Added: trunk/server/test/flags.t
===================================================================
--- trunk/server/test/flags.t 2006-09-04 05:49:01 UTC (rev 341)
+++ trunk/server/test/flags.t 2006-09-04 06:00:51 UTC (rev 342)
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 6;
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use MemcachedTest;
+
+my $server = new_memcached();
+my $sock = $server->sock;
+
+# set foo (and should get it)
+for my $flags (0, 123, 2**16-1) {
+ print $sock "set foo $flags 0 6\r\nfooval\r\n";
+ is(scalar <$sock>, "STORED\r\n", "stored foo");
+ mem_get_is({ sock => $sock,
+ flags => $flags }, "foo", "fooval", "got flags $flags back");
+}
Property changes on: trunk/server/test/flags.t
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/server/test/lib/MemcachedTest.pm
===================================================================
--- trunk/server/test/lib/MemcachedTest.pm 2006-09-04 05:49:01 UTC (rev 341)
+++ trunk/server/test/lib/MemcachedTest.pm 2006-09-04 06:00:51 UTC (rev 342)
@@ -15,8 +15,11 @@
sub mem_get_is {
# works on single-line values only. no newlines in value.
- my $sock = shift;
- my ($key, $val, $msg) = @_;
+ my ($sock_opts, $key, $val, $msg) = @_;
+ my $opts = ref $sock_opts eq "HASH" ? $sock_opts : {};
+ my $sock = ref $sock_opts eq "GLOB" ? $sock_opts : $opts->{sock};
+ my $expect_flags = $opts->{flags} || 0;
+
my $dval = defined $val ? "'$val'" : "<undef>";
$msg ||= "$key == $dval";
print $sock "get $key\r\n";
@@ -25,7 +28,7 @@
} else {
my $len = length($val);
my $body = scalar(<$sock>) . scalar(<$sock>) . scalar(<$sock>);
- Test::More::is($body, "VALUE $key 0 $len\r\n$val\r\nEND\r\n", $msg);
+ Test::More::is($body, "VALUE $key $expect_flags $len\r\n$val\r\nEND\r\n", $msg);
}
}
More information about the memcached-commits
mailing list