Skip to content

Commit

Permalink
Simplify package list diff tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferki committed Jul 29, 2023
1 parent 21a2852 commit 2675153
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .perlcriticrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private_name_regex = _(?!_)\w+
private_name_regex = _(?!_)\w+

[TooMuchCode::ProhibitDuplicateLiteral]
allowlist = 'vim' 1.0 'rex' 'libssh2-1' 'mc'
allowlist = 'vim' 1.0 'rex' 0.52.0 'libssh2-1' 0.32.1 'mc' 2.0

[-ValuesAndExpressions::ProhibitConstantPragma]

Expand Down
36 changes: 21 additions & 15 deletions t/package.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 5;
use Test::More tests => 1;
use Test::Deep;

use Rex::Pkg::Base;

Expand All @@ -23,21 +24,26 @@ my @plist2 = (
{ name => 'libssh2-1', version => '0.32.1' },
);

my @mods = $pkg->diff_package_list( \@plist1, \@plist2 );

my $found_vim = grep { $_->{name} eq "vim" } @mods;
is( $found_vim, 0, "vim was not modified" );

my ($found_rex) = grep { $_->{name} eq "rex" } @mods;
is( $found_rex->{action}, "updated", "rex was updated" );

my ($found_libssh2) = grep { $_->{name} eq "libssh2-1" } @mods;
is( $found_libssh2->{action}, "installed", "libssh2-1 was installed" );
my @expected = (
{
action => 'updated',
name => 'rex',
version => '0.52.0',
},
{
action => 'removed',
name => 'mc',
version => '2.0',
},
{
action => 'installed',
name => 'libssh2-1',
version => '0.32.1',
},
);

my ($found_mc) = grep { $_->{name} eq "mc" } @mods;
is( $found_mc->{action}, "removed", "mc was removed" );
my @mods = $pkg->diff_package_list( \@plist1, \@plist2 );

my $leftover_found = scalar grep { defined $_->{found} } @mods;
is( $leftover_found, 0, 'no internal found marker left' );
cmp_deeply( \@mods, \@expected, 'expected package modifications' );

1;

0 comments on commit 2675153

Please sign in to comment.