-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use Test::More tests =>12; | ||
use FindBin qw($Bin); | ||
use lib "$Bin/lib"; | ||
use MemcachedTest; | ||
|
||
my $engine = shift; | ||
my $server = get_memcached($engine); | ||
my $sock = $server->sock; | ||
|
||
my $cmd; | ||
my $val; | ||
my $rst; | ||
my $expire; | ||
|
||
# Initialize | ||
$cmd = "set key 0 0 5"; $val = "datum"; $rst = "STORED"; | ||
mem_cmd_is($sock, $cmd, $val, $rst); | ||
|
||
# Success Cases | ||
# key value | ||
$cmd = "gat 1 key"; | ||
$rst = "VALUE key 0 5\n" | ||
. "datum\n" | ||
. "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr key expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
# gats command | ||
$cmd = "gats 1 key"; | ||
$rst = "VALUE key 0 5 1\n" | ||
. "datum\n" | ||
. "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr key expiretime"; | ||
$rst = "ATTR expiretime=1\n" | ||
. "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
|
||
# Fail Cases | ||
# bad value | ||
$cmd = "set key 0 0 5"; $val = "datum"; $rst = "STORED"; | ||
mem_cmd_is($sock, $cmd, $val, $rst); | ||
$cmd = "gat str key"; $rst = "CLIENT_ERROR invalid exptime argument"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
# not exist key | ||
$expire = time() - 1; | ||
$cmd = "gat $expire key"; | ||
$rst = "VALUE key 0 5\n" | ||
. "datum\n" | ||
. "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "gat 1 key"; $rst = "CLIENT_ERROR key not found"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
# collection type | ||
$cmd = "lop create lkey 0 0 5"; $rst = "CREATED"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "gat 1 lkey"; $rst = "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
$cmd = "getattr lkey expiretime"; | ||
$rst = "ATTR expiretime=0\n" | ||
. "END"; | ||
mem_cmd_is($sock, $cmd, "", $rst); | ||
|
||
# after test | ||
release_memcached($engine, $server); |