Browse files

Eliminate use of Clone.

Just read the JSON from a file and decode it every time it's needed.
  • Loading branch information...
1 parent 9e36e7e commit e4c2452210f443fdc6ab1d9255f987c77ca3cbf6 @theory theory committed May 24, 2011
Showing with 9 additions and 65 deletions.
  1. +0 −1 Build.PL
  2. +9 −64 t/validator.t
View
1 Build.PL
@@ -8,7 +8,6 @@ Module::Build->new(
create_makefile_pl => 'traditional',
configure_requires => { 'Module::Build' => '0.30' },
build_requires => {
- 'Clone' => 0,
'Module::Build' => '0.30',
'Test::More' => '0.88',
},
View
73 t/validator.t
@@ -1,71 +1,16 @@
use strict;
use warnings;
use Test::More 0.88;
+use JSON;
+use File::Spec;
use PGXN::Meta::Validator;
-use Clone qw(clone);
-my $distmeta = {
- name => 'pgTAP',
- abstract => 'TAP-driven unit testing for PostgreSQL',
- description => 'pgTAP is a suite of database functions that make it easy '
- . 'to write TAP-emitting unit tests in psql scripts or xUnit-'
- . 'style test functions.',
- version => '0.24.0',
- maintainer => [
- 'David Wheeler <theory@pgxn.org>',
- 'pgTAP List <pgtap-users@pgfoundry.org>' # additional contact
- ],
- release_status => 'stable',
- license => [ 'postgresql' ],
- prereqs => {
- runtime => {
- requires => {
- 'PostgreSQL' => '8.0.0',
- 'plpgsql' => '0',
- },
- recommends => {
- 'PostgreSQL' => '8.4.0',
- },
- },
- build => {
- requires => {
- 'plperl' => '0',
- },
- }
- },
- provides => {
- pgtap => {
- abstract => "Unit testing for PostgreSQL",
- file => "pgtap.sql",
- version => "0.26.0"
- }
- },
- resources => {
- 'homepage' => 'http://pgtap.org/',
- 'bugtracker' => {
- 'web' => 'https://github.com/theory/pgtap/issues'
- },
- 'repository' => {
- 'url' => 'https://github.com/theory/pgtap.git',
- 'web' => 'https://github.com/theory/pgtap',
- 'type' => 'git'
- }
- },
- 'tags' => [
- "testing",
- "unit testing",
- "tap",
- "tddd",
- "test driven database development"
- ],
- 'meta-spec' => {
- version => '1.0.0',
- url => 'http://pgxn.org/meta/spec.txt',
- },
- generated_by => 'David E. Wheeler',
- x_authority => 'cpan:FLORA',
- X_deep => { deep => 'structure' },
+my $json = do {
+ my $file = File::Spec->catfile(qw(t META.json));
+ local $/;
+ open my $fh, '<:raw', $file or die "Cannot open $file: $!\n";
+ <$fh>;
};
# Valid metadata.
@@ -239,7 +184,7 @@ for my $spec (
],
) {
my ($desc, $sub) = @{ $spec };
- my $dm = clone $distmeta;
+ my $dm = decode_json $json;
$sub->($dm);
my $pmv = PGXN::Meta::Validator->new($dm);
ok $pmv->is_valid, "Should be valid with $desc"
@@ -629,7 +574,7 @@ for my $spec (
],
) {
my ($desc, $sub, $err) = @{ $spec };
- my $dm = clone $distmeta;
+ my $dm = decode_json $json;
$sub->($dm);
my $pmv = PGXN::Meta::Validator->new($dm);
ok !$pmv->is_valid, "Should be invalid with $desc";

0 comments on commit e4c2452

Please sign in to comment.