summaryrefslogtreecommitdiff
path: root/t/spore-request/base.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/base.t
downloadnet-http-spore-3e3dc478fc9b4eb90681df89156dfcc8f7f81481.tar.gz
initial import
Diffstat (limited to '')
-rw-r--r--t/spore-request/base.t71
1 files changed, 71 insertions, 0 deletions
diff --git a/t/spore-request/base.t b/t/spore-request/base.t
new file mode 100644
index 0000000..7ae91e9
--- /dev/null
+++ b/t/spore-request/base.t
@@ -0,0 +1,71 @@
+use strict;
+use warnings;
+
+use Net::HTTP::Spore::Request;
+
+use Test::More;
+
+my @tests = (
+ {
+ host => 'localhost',
+ base => 'http://localhost/'
+ },
+ {
+ script_name => '/foo',
+ host => 'localhost',
+ base => 'http://localhost/foo'
+ },
+ {
+ script_name => '/foo bar',
+ host => 'localhost',
+ base => 'http://localhost/foo%20bar'
+ },
+ {
+ scheme => 'http',
+ host => 'localhost:91',
+ base => 'http://localhost:91/'
+ },
+ {
+ scheme => 'http',
+ host => 'example.com',
+ base => 'http://example.com/'
+ },
+ {
+ scheme => 'https',
+ host => 'example.com',
+ base => 'https://example.com/'
+ },
+ {
+ scheme => 'http',
+ server_name => 'example.com',
+ server_port => 80,
+ base => 'http://example.com/'
+ },
+ {
+ scheme => 'http',
+ server_name => 'example.com',
+ server_port => 8080,
+ base => 'http://example.com:8080/'
+ },
+ {
+ host => 'foobar.com',
+ server_name => 'example.com',
+ server_port => 8080,
+ base => 'http://foobar.com/'
+ },
+);
+
+plan tests => 1 * @tests;
+
+for my $block (@tests) {
+ my $env = {
+ 'spore.url_scheme' => $block->{scheme} || 'http',
+ HTTP_HOST => $block->{host} || undef,
+ SERVER_NAME => $block->{server_name} || undef,
+ SERVER_PORT => $block->{server_port} || undef,
+ SCRIPT_NAME => $block->{script_name} || '',
+ };
+
+ my $req = Net::HTTP::Spore::Request->new($env);
+ is $req->base, $block->{base};
+}