2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-09-30 14:55:17 +00:00

test(xcat-dep): cover the shared mock config resolver

An AlmaLinux host resolves to the alma config file, an id that names its
file resolves to it, the os-release id wins when both files exist, and a
release with no config file is an error that names the files it tried.
This commit is contained in:
Vinícius Ferrão
2026-09-25 02:25:44 -03:00
parent f8f77db1d6
commit 0ba9df8dc8
+19 -1
View File
@@ -12,7 +12,7 @@ use File::Path qw(make_path);
use File::Basename qw(basename);
use MockBuildUtils qw(install_deps_packages install_deps_command missing_perl_modules
required_pkgs version_matches rpm_sigmd5 rpm_version rpm_release rpm_is_signed
rpm_arch rpm_in_cell
rpm_arch rpm_in_cell resolve_mock_cfg
skipped_builder carry_over_rpms source_package
restamp_release_line cross_copy_genesis finalize_xcat_dep read_manifest
verify_repo_packages verify_repo_signature verify_rpm_signatures
@@ -31,6 +31,24 @@ sub quiet(&) {
return wantarray ? @r : $r[0];
}
# ---- resolve_mock_cfg: /etc/os-release says almalinux, mock-core-configs names the file alma -----
{
my $dir = tempdir(CLEANUP => 1);
my $touch = sub { open(my $fh, '>', "$dir/$_[0].cfg") or die "$_[0]: $!"; close($fh); };
$touch->('alma+epel-10-x86_64');
$touch->('rocky+epel-9-x86_64');
is(eval { resolve_mock_cfg('almalinux', 10, 'x86_64', $dir) }, 'alma+epel-10-x86_64',
'an AlmaLinux host resolves to the alma config file');
is(eval { resolve_mock_cfg('rocky', 9, 'x86_64', $dir) }, 'rocky+epel-9-x86_64',
'an id that names its config file resolves to it');
$touch->('almalinux+epel-10-x86_64');
is(eval { resolve_mock_cfg('almalinux', 10, 'x86_64', $dir) }, 'almalinux+epel-10-x86_64',
'a config file named after the os-release id is preferred');
ok(!eval { resolve_mock_cfg('almalinux', 8, 'x86_64', $dir); 1 },
'a release with no config file is an error');
like($@, qr{\Q$dir/alma+epel-8-x86_64.cfg\E}, 'the error names the config files it tried');
}
# ---- required_pkgs: a skipped builder's packages are not required (clean --skip-* runs) -------
my @all = qw(elilo-xcat ipmitool-xcat perl-IO-Stty perl-Sys-Virt xCAT-genesis-base);
is_deeply([required_pkgs(\@all, 0, 0, 0)], \@all,