File: dh-raku-internals.t

package info (click to toggle)
dh-make-raku 0.8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: perl: 595; makefile: 4
file content (79 lines) | stat: -rw-r--r-- 2,675 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use strict;
use warnings;
use v5.20;

use Test::More;
use Path::Tiny;
use Config::Model qw/cme/;

use DhMakeRaku;

subtest "update debian copyright" => sub {
    my $email = $ENV{DEBEMAIL} = 'jb@team.org';
    my $name = $ENV{DEBFULLNAME} = 'Joe Bar';
    my @l = localtime;
    my $year = $l[5]+1900;
    my $oldyear = $year - 1;

    my @tests = (
        [ __LINE__, undef , "$year, $name <$email>" ],
        [ __LINE__, '2015, Marcel Mézigues <marcel@nowhere>' => "{}\n$year, $name <$email>" ],
        [ __LINE__, "2015, $name <$email>" => "2015, $year, $name <$email>" ],
        [ __LINE__, "2015, $oldyear, $name <$email>" => "2015, $oldyear-$year, $name <$email>" ],
        [ __LINE__, "2015-$oldyear, $name <$email>" => "2015-$year, $name <$email>" ],
    );

    foreach my $test( @tests ) {
        $test->[2] =~ s/{}/$test->[1]/e;
        my $new_cop = DhMakeRaku::update_debian_copyright($test->[1]);
        is($new_cop, $test->[2],"check copyright entry line $test->[0]");
    }
};

subtest "get_description" => sub {
    my $package = 'raku-file-find';
    my $target = path("t/samples/$package");
    chdir($target);

    my $instance = cme('dpkg');
    my $root = $instance->config_root;

    my $desc = $root->grab("control binary:$package Description");
    DhMakeRaku::setup_control ($root, $target, 'dummy-git', 'raku-file-find');

    like($desc->fetch, qr/please fill/i, "default value when no description is found");

    $desc->store("Dummy description");

    DhMakeRaku::setup_control ($root, $target, 'dummy-git', 'raku-file-find');

    like($desc->fetch, qr/dummy description/i, "User value not clobbered when no description is found");
};

subtest "get_watch_content" => sub {
    my $package = 'raku-file-find';
    my @tests = (
         __LINE__, 'https://github.com/plop.git' , qr!com/plop/tags! ,
         __LINE__, 'https://gitother.com/plop.git' , qr!plop\.git! ,
    );

    while (my ($line, $git, $exp) = splice @tests, 0,3 ) {
        my $watch = DhMakeRaku::get_watch_content($git, $package);
        like($watch, $exp, "check $git watch file (from line $line)");
    }
};

subtest "translate dependencies" => sub{
    my @tests = (
        __LINE__, 'Hash::Merge:version<1.0.1>' => 'raku-hash-merge (>= 1.0.1)',
        __LINE__, "Log:auth<cpan:TYIL>:version<0.3.0>" => 'raku-log (>= 0.3.0)',
        __LINE__, "JSON::Marshal:ver<0.0.25+>" => 'raku-json-marshal (>= 0.0.25)',
    );

    while (my ($line, $raku_dep, $deb_dep, $exp) = splice @tests, 0,3 ) {
        my $res = DhMakeRaku::raku_dep_to_debian_dep($raku_dep);
        is($res, $deb_dep, "translater raku dep $raku_dep (from line $line)");
    }
};

done_testing;