Stas Bekman wrote:
I think all kind of refactoring would be great. One thing I wanted to do for tests again vhosts, is to add this function next to module2path():
sub module2url { my $module = shift; my $scheme = shift || "http";
Apache::TestRequest::module($module); my $config = Apache::Test::config(); my $hostport = Apache::TestRequest::hostport($config); my $path = Apache::TestRequest::module2path($module); return "$scheme://$hostport$path"; }
and then replace the long craft used a lot in the modperl tests, so now one can write a simple:
my $module = "Foo::bar"; { my $path = Apache::TestRequest::module2path($module); GET $path; # GET "/Foo__bar" } { my $url = Apache::TestRequest::module2url($module); GET $url; # GET "http://localhost:8545/Foo__bar" }
After another look at things like t/merge.t, it looks like there are at least 2 different use cases for module2perl.
1) The $module sent to module2perl will be sent to ::module() and will be the same as the path. This is your first example:
Foo::Bar => /Foo__Bar
2) The $module sent to module2perl will be sent to ::module(), but a DIFFERENT path is required; like in merge3.t where the path == '/merge3/ != TestModperl::merge
What about make mopdeul2url have a hashref as the second arg in which we can override $path, and of course $scheme
Apache::TestRequest::module2path('TestModePerl::merge', { scheme => 'https', path => '/merge3/ }
Isn't merge3 an odd ball? Originally I was thinking to do the refactoring for the code which identical and leave the more complex cases alone. But if you wish to implement the suggested functionality go for it. It definitely makes the test more readable, and those wishing to use the old functionality still can do that.
though it's module2url, not module2path (saw your update)
> Of course it should take the necessary precautions for when / is and > isn't included, etc.
What do you mean? Examples?
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com