File-Corresponding

 view release on metacpan or  search on metacpan

t/corresponding-corresponding.t  view on Meta::CPAN


use strict;
use warnings;
use Test::More tests => 5;
use Test::Exception;
use Test::Differences;

use File::chdir;
use File::Basename;
use Path::Class qw/ dir file /;


use lib "lib";

use File::Corresponding;
use File::Corresponding::Group;
use File::Corresponding::File::Profile;
use File::Corresponding::File::Found;




{
    local $CWD = dir( dirname(__FILE__), "data" );


    diag("Setup a config to match things under data/corresponding");
    ok(
        my $group_a = File::Corresponding::Group->new({
            name => "Number files",
            file_profiles => [
                my $profile_abc = File::Corresponding::File::Profile->new({
                    name    => "abc",
                    regex   => qr|abc/([\w.]+)$|,
                    sprintf => "abc/%s"
                }),
                my $profile_def = File::Corresponding::File::Profile->new({
                    name    => "def",
                    regex   => qr|elsewhere/def/([\w.]+)$|,
                    sprintf => "elsewhere/def/%s"
                }),
                my $profile_ghi = File::Corresponding::File::Profile->new({
                    name    => "ghi",
                    regex   => qr|ghi/([\w.]+)$|,
                    sprintf => "ghi/%s"
                }),
            ],
        }),
        "Create new group ok",
    );

    ok(
        my $group_b = File::Corresponding::Group->new({
            name => "Number files",
            file_profiles => [
                $profile_ghi,
                my $profile_jkl = File::Corresponding::File::Profile->new({
                    name    => "jkl",
                    regex   => qr|jkl/([\w.]+)$|,
                    sprintf => "jkl/%s"
                }),
            ],
        }),
        "Create new group ok",
    );



( run in 0.853 second using v1.01-cache-2.11-cpan-2398b32b56e )