diff --git a/lib/ShardedKV/Storage/Rest.pm b/lib/ShardedKV/Storage/Rest.pm index 175edac..60f609d 100644 --- a/lib/ShardedKV/Storage/Rest.pm +++ b/lib/ShardedKV/Storage/Rest.pm @@ -114,6 +114,9 @@ sub delete { if ($code >= 200 && $code < 300) { return 1; } + if ($code == 404) { + return 1; # already gone + } return 0; } diff --git a/t/rest.t b/t/rest.t index 26a4540..b098ce8 100755 --- a/t/rest.t +++ b/t/rest.t @@ -60,6 +60,9 @@ sub Test::HTTP::Server::Request::test } } elsif ($self->{request}->[0] eq 'DELETE') { $self->{out_headers}->{'Content-Length'} = 0; + if ($path =~ m@\A /test/DELETE-(\d{3}) \z@x) { + $self->{out_code} = "$1 ($1 Response)"; + } unlink "$tempdir/$key.$me"; } return ""; @@ -121,5 +124,17 @@ foreach my $i (0..$num_items) { is($skv->get("${key}$i"), undef); } +# Multiple delete ok +is($skv->delete("${key}0"), 1); +is($skv->delete("${key}0"), 1); + +# Delete successes +is($skv->delete("DELETE-200"), 1); +is($skv->delete("DELETE-204"), 1); +is($skv->delete("DELETE-404"), 1); + +# Delete failures +is($skv->delete("DELETE-403"), 0); +is($skv->delete("DELETE-500"), 0); done_testing();