File: version-default.t

package info (click to toggle)
libdist-zilla-plugin-git-perl 2.051-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 1,306; makefile: 11
file content (59 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use Test::More 0.88 tests => 9;

use lib 't/lib';
use Util qw(:DEFAULT zilla_version);

init_test(corpus => 'version-default');

## shortcut for new tester object
sub new_zilla_version {
  new_zilla_from_repo;
  zilla_version;
}

## Tests start here

# with no tags and no initialization, should get default
is( new_zilla_version, "0.001", "works with no commits" );

$git->add(".");
$git->commit({ message => 'import' });

# with no tags and no initialization, should get default
is( new_zilla_version, "0.001", "default is 0.001" );

# initialize it
{
    local $ENV{V} = "1.23";
    is( new_zilla_version, "1.23", "initialized with \$ENV{V}" );
}

# add a tag that doesn't match the regex
$git->tag("revert-me-later");
ok( (grep { /revert-me-later/ } $git->tag), "wrote revert-me-later tag" );
{
    is( new_zilla_version, "0.001", "default is 0.001" );
}

# tag it
$git->tag("v1.2.3");
ok( (grep { /v1\.2\.3/ } $git->tag), "wrote v1.2.3 tag" );

{
    is( new_zilla_version, "1.2.4", "initialized from last tag" );
}

# tag it
$git->tag("v1.23");
ok( (grep { /v1\.23/ } $git->tag), "wrote v1.23 tag" );

{
    is( new_zilla_version, "1.24", "initialized from last tag" );
}



done_testing;