Skip to content

Commit

Permalink
fix group set_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Feb 20, 2024
1 parent 0a62dce commit 3c7171c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/CPAN/Changes/Group.pm
Expand Up @@ -61,8 +61,12 @@ sub changes {

sub set_changes {
my ($self, @changes) = @_;
my $entry = $self->_entry->clone(entries => \@changes);
$self->_entry($entry);
$self->clear_changes;
my $entry = $self->_entry;
for my $change (@changes) {
$entry->add_entry($change);
}
return;
}

sub clear_changes {
Expand Down
17 changes: 17 additions & 0 deletions t/group.t
Expand Up @@ -2,6 +2,7 @@ use strict;
use warnings;
use Test::More;

use CPAN::Changes;
use CPAN::Changes::Parser;

my $parser = CPAN::Changes::Parser->new;
Expand All @@ -15,4 +16,20 @@ my $parser = CPAN::Changes::Parser->new;
is eval { $groups[0]->name }, '', 'group has empty name';
}

{
my $changes = CPAN::Changes->new;
$changes->add_release({version => '1.0'});
my $release = $changes->release('1.0');
my $entry = $release->add_entry('welp');
my $sub_entry = $entry->add_entry('welp');
my ($group) = ($release->group_values);
$group->set_changes(
'guff',
'blorf',
);

is join(',', map $_->text, @{$entry->entries}), 'guff,blorf',
'set_changes properly sets entries';
}

done_testing;

0 comments on commit 3c7171c

Please sign in to comment.