summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-04-01 17:08:31 +0200
committerfranck cuny <franck@lumberjaph.net>2010-04-01 17:08:31 +0200
commit0f7ea4b0f5d345f9b0b7a2f7b057d82aa6d7a4e6 (patch)
treeb25bde33bba13254c874c2ded6c04ac5e0da4c26
parentadd tests (diff)
downloadplack-middleware-throttle-0f7ea4b0f5d345f9b0b7a2f7b057d82aa6d7a4e6.tar.gz
update tests
-rw-r--r--t/04_combine.t25
1 files changed, 19 insertions, 6 deletions
diff --git a/t/04_combine.t b/t/04_combine.t
index 31a4e98..91a6269 100644
--- a/t/04_combine.t
+++ b/t/04_combine.t
@@ -8,9 +8,16 @@ use HTTP::Request::Common;
 use Plack::Middleware::Throttle::Backend::Hash;
 
 my $handler = builder {
+    enable "Throttle::Interval",
+        min     => 2,
+        backend => Plack::Middleware::Throttle::Backend::Hash->new();
     enable "Throttle::Hourly",
-        max     => 2,
+        max     => 4,
+        backend => Plack::Middleware::Throttle::Backend::Hash->new();
+    enable "Throttle::Daily",
+        max     => 6,
         backend => Plack::Middleware::Throttle::Backend::Hash->new();
+
     sub { [ '200', [ 'Content-Type' => 'text/html' ], ['hello world'] ] };
 };
 
@@ -19,16 +26,22 @@ test_psgi
     client => sub {
     my $cb = shift;
     {
+        my $req = GET "http://localhost/";
+        my $res = $cb->($req);
+        is $res->code, 200, 'http response is 200';
         for ( 1 .. 2 ) {
             my $req = GET "http://localhost/";
             my $res = $cb->($req);
-            is $res->code, 200, 'http response is 200';
-            ok $res->headers('X-RateLimit-Limit'), 'header ratelimit';
+            is $res->code, 503, 'http response is 503';
         }
-        my $req = GET "http://localhost/";
-        my $res = $cb->($req);
+        sleep(3);
+        $req = GET "http://localhost/";
+        $res = $cb->($req);
+        is $res->code, 200, 'http response is 200';
+	sleep(3);
+        $req = GET "http://localhost/";
+        $res = $cb->($req);
         is $res->code, 503, 'http response is 503';
-        ok $res->headers('X-RateLimit-Reset'), 'header reset';
     }
     };