Permalink
Browse files

more tests

  • Loading branch information...
1 parent 0f35e24 commit 3d1d6f14a0a21fb9e6fdc51fc861cc6de2845332 Stevan Little committed Mar 18, 2012
Showing with 55 additions and 1 deletion.
  1. +25 −1 t/010-resource-tests.t
  2. +14 −0 t/010-resources/G11.pm
  3. +16 −0 t/010-resources/H12.pm
View
@@ -154,7 +154,7 @@ my @tests = (
request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_ACCEPT_ENCODING => 'gzip' },
response => [ 406, [ 'Content-Type' => 'text/plain' ], [] ]
},
- # ...
+ # ... (test out all the different variance scenarios, this really is testing G7, but H7 is the terminal node)
{
resource => 'H7',
request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_ACCEPT => 'text/plain', HTTP_ACCEPT_LANGUAGE => 'de', HTTP_ACCEPT_CHARSET => 'utf-8', HTTP_ACCEPT_ENCODING => 'gzip', HTTP_IF_MATCH => '*' },
@@ -185,6 +185,30 @@ my @tests = (
request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_ACCEPT => 'text/plain', HTTP_ACCEPT_LANGUAGE => 'de', HTTP_ACCEPT_CHARSET => 'utf-8', HTTP_ACCEPT_ENCODING => 'gzip', HTTP_IF_MATCH => '*' },
response => [ 412, [ 'Vary' => 'Accept, Accept-Language', 'Content-Encoding' => 'gzip', 'Content-Language' => 'de', 'Content-Type' => 'text/plain;charset=utf-8', ], [] ]
},
+ # ...
+ {
+ resource => 'G11',
+ request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_IF_MATCH => '0xDEADPORK' },
+ response => [ 412, [ 'Content-Encoding' => 'gzip', 'Content-Type' => 'text/plain' ], [] ]
+ },
+ # ... H12 via G8->H10->H11
+ {
+ resource => 'H12',
+ request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_IF_UNMODIFIED_SINCE => '18 Mar 2012 15:49:00 GMT' },
+ response => [ 412, [ 'Content-Encoding' => 'gzip', 'Content-Type' => 'text/plain' ], [] ]
+ },
+ # ... H12 via G8->G9->H10->H11
+ {
+ resource => 'H12',
+ request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_IF_MATCH => '*', HTTP_IF_UNMODIFIED_SINCE => '18 Mar 2012 15:49:00 GMT' },
+ response => [ 412, [ 'Content-Encoding' => 'gzip', 'Content-Type' => 'text/plain' ], [] ]
+ },
+ # ... H12 via G8->G9->G11->H10->H11
+ {
+ resource => 'H12',
+ request => { REQUEST_METHOD => 'GET', SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '/', HTTP_IF_UNMODIFIED_SINCE => '18 Mar 2012 15:49:00 GMT', HTTP_IF_MATCH => '0xDEADPORK' },
+ response => [ 412, [ 'Content-Encoding' => 'gzip', 'Content-Type' => 'text/plain' ], [] ]
+ },
);
foreach my $test ( @tests ) {
View
@@ -0,0 +1,14 @@
+package G11;
+use strict;
+use warnings;
+
+use parent 'Web::Machine::Resource';
+
+sub content_types_provided { [ { 'text/plain' => sub {} } ] }
+sub languages_provided { [qw[ de ]] }
+sub charsets_provided { [ { 'utf-8' => sub {} } ] }
+sub encodings_provided { +{ 'gzip' => sub {} } }
+
+sub generate_etag { '0xDEADBEEF' }
+
+1;
View
@@ -0,0 +1,16 @@
+package H12;
+use strict;
+use warnings;
+
+use parent 'Web::Machine::Resource';
+
+sub content_types_provided { [ { 'text/plain' => sub {} } ] }
+sub languages_provided { [qw[ de ]] }
+sub charsets_provided { [ { 'utf-8' => sub {} } ] }
+sub encodings_provided { +{ 'gzip' => sub {} } }
+
+sub generate_etag { '0xDEADBEEF' }
+
+sub last_modified { '18 Mar 2012 15:50:00 GMT' }
+
+1;

0 comments on commit 3d1d6f1

Please sign in to comment.