1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
use strict;
use warnings;
use Test::More;
use Module::Faker;
use File::Temp ();
my $MF = 'Module::Faker';
my $tmpdir = File::Temp::tempdir(CLEANUP => 1);
$MF->make_fakes({
source => './eg',
dest => $tmpdir,
});
ok(
-e "$tmpdir/Mostly-Auto-0.01.tar.gz",
"we got the mostly-auto dist",
);
is((stat("$tmpdir/Mostly-Auto-0.01.tar.gz"))[9], 100, "got mtime set");
subtest "from YAML file" => sub {
my $dist = Module::Faker::Dist->from_file('./eg/RJBS-Dist.yml');
is($dist->cpan_author, 'RJBS', "get cpan author from Faker META section");
};
subtest "from .dist file" => sub {
my $dist = Module::Faker::Dist->from_file('./eg/RJBS_Another-Dist-1.24.tar.gz.dist');
is($dist->cpan_author, 'RJBS', "get cpan author from .dist filename");
is($dist->name, 'Another-Dist', "correct dist name");
is($dist->version, '1.24', "correct version");
};
subtest "from struct, with undef version" => sub {
my $dist = Module::Faker::Dist->new({name => 'Some-Dist', version => undef});
is($dist->name, 'Some-Dist', "correct dist name");
is($dist->version, undef, "correct version");
is($dist->archive_basename, 'Some-Dist-undef', "correct basename");
};
subtest "from struct, written to a zip" => sub {
my $dist = Module::Faker::Dist->new({ name => 'Some-Dist', version => '1.23' });
# We're not goign to test anything yet, but just make sure that this works,
# in case someday Archive::Any::Create is changed in a way that breaks our
# hack.
my $filename = $dist->make_archive({ dir => $tmpdir });
ok(-e $filename, "we wrote the archive");
};
done_testing;
|