Permalink
Browse files

Supply an empty metadata for package (to return module's VERSION in m…

…etadata more easily)
  • Loading branch information...
1 parent 2123319 commit 119b360c11525b88147ff66393787a5d41d7cddf Steven Haryanto (on PC) committed Jun 15, 2012
Showing with 23 additions and 0 deletions.
  1. +6 −0 lib/Perinci/Access/InProcess.pm
  2. +17 −0 t/access-inprocess.t
@@ -91,6 +91,12 @@ sub _get_code_and_meta {
my $ma = $res->[2];
my $meta = $ma->get_meta($req);
+
+ # supply a default, empty metadata for package, just so we can put $VERSION
+ # into it
+ if (!$meta && $req->{-type} eq 'package') {
+ $meta = {v=>1.1};
+ }
return [404, "No metadata"] unless $meta;
my $code;
View
@@ -7,6 +7,11 @@ use Test::More 0.96;
use Perinci::Access::InProcess;
+package Foo;
+
+package Bar;
+our $VERSION = 0.123;
+
package Test::Perinci::Access::InProcess;
our %SPEC;
@@ -93,6 +98,18 @@ test_request(
entity_version => $Test::Perinci::Access::InProcess::VERSION },
);
test_request(
+ name => 'meta on package (default meta)',
+ req => [meta => "/Foo/"],
+ status => 200,
+ result => { v => 1.1 },
+);
+test_request(
+ name => 'meta on package (default meta + version)',
+ req => [meta => "/Bar/"],
+ status => 200,
+ result => { v => 1.1, entity_version => 0.123 },
+);
+test_request(
name => 'ending slash matters',
req => [meta => "/Perinci/Examples"],
status => 404,

0 comments on commit 119b360

Please sign in to comment.