Bug 30731: Unit tests

Installer_pm.t can safely be discarded, having Installer_PerlModules.t.

Note: Without the second patch, the test about versions_info being silent
might fail. With the second patch, it should pass.
Note that since the order of requiring the cpan modules varies (without
the second patch), the results (potential warnings) vary too.

Test plan:
Run t/Installer_PerlModules.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2022-05-11 14:35:18 +00:00 committed by Tomas Cohen Arazi
parent f6110ce417
commit 2265739a37
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 12 additions and 24 deletions

View File

@ -5,23 +5,26 @@
use Modern::Perl;
use Test::More tests => 6;
use Test::More tests => 3;
use Test::Warn;
BEGIN {
use_ok('C4::Installer::PerlModules');
}
my $modules;
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object');
my $prereq_pm = $modules->prereq_pm();
ok (exists($prereq_pm->{"DBI"}), 'DBI required for installer to run');
ok (exists($prereq_pm->{"CGI"}), 'CGI required for installer to run' );
ok (exists($prereq_pm->{"YAML::XS"}), 'YAML::XS required for installer to run');
subtest 'prereq_pm' => sub {
my $modules;
ok ($modules = C4::Installer::PerlModules->new(), 'Tests modules object');
my $prereq_pm = $modules->prereq_pm();
ok (exists($prereq_pm->{"DBI"}), 'DBI required for installer to run');
ok (exists($prereq_pm->{"CGI"}), 'CGI required for installer to run' );
ok (exists($prereq_pm->{"YAML::XS"}), 'YAML::XS required for installer to run');
};
subtest 'versions_info' => sub {
plan tests => 4;
plan tests => 5;
my $modules = C4::Installer::PerlModules->new;
$modules->versions_info;
warning_is { $modules->versions_info } undef, 'No warnings from versions_info';
ok( exists $modules->{missing_pm}, 'versions_info fills the missing_pm key' );
ok( exists $modules->{upgrade_pm}, 'versions_info fills the upgrade_pm key' );
ok( exists $modules->{current_pm}, 'versions_info fills the current_pm key' );

View File

@ -1,15 +0,0 @@
#!/usr/bin/perl
#
use strict;
use warnings;
use Test::More tests => 2;
use Data::Dumper;
BEGIN {
use_ok('C4::Installer::PerlModules');
}
my $obj = C4::Installer::PerlModules->new;
isa_ok($obj,'C4::Installer::PerlModules');