X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=t%2F01basics.t;h=2b1518dead6a4b6a2d34c9c766d65d83b14bd5d4;hb=8617321ebf13ce6b63d41a65a003d153f2b5cc5e;hp=9c3d4b9531cbcf6d05a972e85d4fe00af2d7c206;hpb=24259799350483f32219fd3755e0bed54f909c54;p=maypole.git diff --git a/t/01basics.t b/t/01basics.t index 9c3d4b9..2b1518d 100644 --- a/t/01basics.t +++ b/t/01basics.t @@ -1,17 +1,35 @@ # vim:ft=perl use Test::More; use lib 'ex'; # Where BeerDB should live -BEGIN { if (eval { require BeerDB }) { - plan tests => 12; - } else { Test::More->import(skip_all =>"SQLite not working or BeerDB module could not be loaded: $@") } - } +BEGIN { + eval { require BeerDB }; + Test::More->import( skip_all => + "SQLite not working or BeerDB module could not be loaded: $@" + ) if $@; + + plan tests => 15; +} use Maypole::CLI qw(BeerDB); use Maypole::Constants; $ENV{MAYPOLE_TEMPLATES} = "t/templates"; isa_ok( (bless {},"BeerDB") , "Maypole"); -like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, "Got the front page"); +BeerDB->config->view_options({COMPILE_DIR => '/home/simon/dev/maypole/compiled'}); + +# Test the effect of trailing slash on config->uri_base and request URI +(my $uri_base = BeerDB->config->uri_base) =~ s:/$::; +BeerDB->config->uri_base($uri_base); +like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, + "Got frontpage, trailing '/' on request but not uri_base"); +like(BeerDB->call_url("http://localhost/beerdb"), qr/frontpage/, + "Got frontpage, no trailing '/' on request or uri_base"); +BeerDB->config->uri_base($uri_base . '/'); +like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, + "Got frontpage, trailing '/' on uri_base and request"); +like(BeerDB->call_url("http://localhost/beerdb"), qr/frontpage/, + "Got frontpage, trailing '/' on uri_base but not request"); + like(BeerDB->call_url("http://localhost/beerdb/beer/list"), qr/Organic Best/, "Found a beer in the list"); my (%classdata)=split /\n/, BeerDB->call_url("http://localhost/beerdb/beer/classdata"); is ($classdata{plural},'beers','classdata.plural');