summaryrefslogtreecommitdiff
path: root/t/spore-request/uri.t
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-09-13 13:31:56 +0200
committerfranck cuny <franck@lumberjaph.net>2010-09-13 13:31:56 +0200
commit3e3dc478fc9b4eb90681df89156dfcc8f7f81481 (patch)
treeb9788b0d48f524bc4c0aeeb48c744a8f7b097910 /t/spore-request/uri.t
downloadnet-http-spore-3e3dc478fc9b4eb90681df89156dfcc8f7f81481.tar.gz
initial import
Diffstat (limited to 't/spore-request/uri.t')
-rw-r--r--t/spore-request/uri.t109
1 files changed, 109 insertions, 0 deletions
diff --git a/t/spore-request/uri.t b/t/spore-request/uri.t
new file mode 100644
index 0000000..d3f8b82
--- /dev/null
+++ b/t/spore-request/uri.t
@@ -0,0 +1,109 @@
+use strict;
+use warnings;
+use Test::More;
+
+use Net::HTTP::Spore::Request;
+
+my @tests = (
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => "",
+ },
+ uri => 'http://example.com/',
+ parameters => {}
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => "",
+ PATH_INFO => "/foo bar",
+ },
+ uri => 'http://example.com/foo%20bar',
+ parameters => {}
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => '/test.c',
+ },
+ uri => 'http://example.com/test.c',
+ parameters => {}
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => '/test.c',
+ PATH_INFO => '/info',
+ },
+ uri => 'http://example.com/test.c/info',
+ parameters => {}
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => '/test',
+ 'spore.params' => [qw/dynamic daikuma/],
+ },
+ uri => 'http://example.com/test?dynamic=daikuma',
+ parameters => { dynamic => 'daikuma' }
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => '/exec/'
+ },
+ uri => 'http://example.com/exec/',
+ parameters => {}
+ },
+ {
+ add_env => { SERVER_NAME => 'example.com' },
+ uri => 'http://example.com/',
+ parameters => {}
+ },
+ {
+ add_env => {},
+ uri => 'http:///',
+ parameters => {}
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => "",
+ 'spore.params' => [qw/aco tie/],
+ },
+ uri => 'http://example.com/?aco=tie',
+ parameters => { aco => 'tie' }
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => "",
+ 'spore.params' => [qw/0/],
+ },
+ uri => 'http://example.com/?0',
+ parameters => {}
+ },
+ {
+ add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => "/foo bar",
+ PATH_INFO => "/baz quux",
+ },
+ uri => 'http://example.com/foo%20bar/baz%20quux',
+ parameters => {}
+ }
+);
+
+plan tests => 1 * @tests;
+
+for my $block (@tests) {
+ my $env = { SERVER_PORT => 80 };
+ while ( my ( $key, $val ) = each %{ $block->{add_env} || {} } ) {
+ $env->{$key} = $val;
+ }
+ my $req = Net::HTTP::Spore::Request->new($env);
+
+ is $req->uri, $block->{uri};
+# is_deeply $req->query_parameters, $block->{parameters};
+}