~yolanda.robla/ubuntu/trusty/memcached/add_distribution

« back to all changes in this revision

Viewing changes to t/issue_3.t

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2010-05-12 11:41:22 UTC
  • mto: (3.3.3 squeeze) (1.1.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: james.westby@ubuntu.com-20100512114122-wpynzm9kb1irw1um
Import upstream version 1.4.5

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 => 8;
 
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
my $key = "del_key";
 
12
 
 
13
print $sock "delete $key\r\n";
 
14
is (scalar <$sock>, "NOT_FOUND\r\n", "not found on delete");
 
15
 
 
16
print $sock "delete $key 10\r\n";
 
17
is (scalar <$sock>, "CLIENT_ERROR bad command line format."
 
18
    . "  Usage: delete <key> [noreply]\r\n", "invalid delete");
 
19
 
 
20
print $sock "add $key 0 0 1\r\nx\r\n";
 
21
is (scalar <$sock>, "STORED\r\n", "Add before a broken delete.");
 
22
 
 
23
print $sock "delete $key 10 noreply\r\n";
 
24
# Does not reply
 
25
# is (scalar <$sock>, "ERROR\r\n", "Even more invalid delete");
 
26
 
 
27
print $sock "add $key 0 0 1\r\nx\r\n";
 
28
is (scalar <$sock>, "NOT_STORED\r\n", "Failed to add after failed silent delete.");
 
29
 
 
30
print $sock "delete $key noreply\r\n";
 
31
# Will not reply, so let's do a set and check that.
 
32
 
 
33
print $sock "set $key 0 0 1\r\nx\r\n";
 
34
is (scalar <$sock>, "STORED\r\n", "Stored a key");
 
35
 
 
36
print $sock "delete $key\r\n";
 
37
is (scalar <$sock>, "DELETED\r\n", "Properly deleted");
 
38
 
 
39
print $sock "set $key 0 0 1\r\nx\r\n";
 
40
is (scalar <$sock>, "STORED\r\n", "Stored a key");
 
41
 
 
42
print $sock "delete $key noreply\r\n";
 
43
# will not reply, but a subsequent add will succeed
 
44
 
 
45
print $sock "add $key 0 0 1\r\nx\r\n";
 
46
is (scalar <$sock>, "STORED\r\n", "Add succeeded after deletion.");
 
47