-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for MiqLinux::Packages for rpm/dpkg
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
require 'metadata/linux/LinuxPackages' | ||
|
||
describe MiqLinux::Packages do | ||
let(:fs) { double("MiqFS") } | ||
|
||
before do | ||
allow(fs).to receive(:fileExists?).and_return(false) | ||
end | ||
|
||
context "with a dpkg status file" do | ||
before do | ||
expect(fs).to receive(:fileExists?).with(MiqLinux::Packages::DPKG_FILE).and_return(true) | ||
expect(fs) | ||
.to receive(:fileOpen) | ||
.with(MiqLinux::Packages::DPKG_FILE) | ||
.and_yield(File.open(File.expand_path("data/dpkg/status", __dir__), "r")) | ||
end | ||
|
||
it "returns a list of rpm packages" do | ||
result = described_class.new(fs) | ||
|
||
expect(result.instance_variable_get(:@packages).count).to eq(1) | ||
end | ||
|
||
it "returns relevent information for each package" do | ||
result = described_class.new(fs) | ||
kernel = result.instance_variable_get(:@packages).first | ||
|
||
expect(kernel.to_h).to include( | ||
:name => "linux-image-6.11.4-amd64", | ||
:status => "install ok installed", | ||
:installed => true, | ||
:category => "kernel", | ||
:description => "Linux 6.11 for 64-bit PCs (signed)\n The Linux kernel 6.11 and modules for use on PCs with AMD64, Intel 64 or\n VIA Nano processors.\n .\n The kernel image is signed for use with Secure Boot.\nBuilt-Using: linux (= 6.11.4-1)\nHomepage: https://www.kernel.org/", | ||
:version => "6.11.4-1", | ||
:depends => "kmod, linux-base (>= 4.3~), initramfs-tools (>= 0.120+deb8u2) | linux-initramfs-tool" | ||
) | ||
end | ||
end | ||
|
||
context "with an RPM directory" do | ||
before do | ||
expect(fs).to receive(:fileDirectory?).with(MiqLinux::Packages::RPM_DB).and_return(true) | ||
end | ||
|
||
context "with a Packages Berkeley DB file" do | ||
before do | ||
expect(fs) | ||
.to receive(:fileOpen) | ||
.with(File.join(MiqLinux::Packages::RPM_DB, "Packages"), "r") | ||
.and_return(File.open(File.expand_path('../../db/MiqBdb/data/rpm/Packages', __dir__), "r")) | ||
end | ||
|
||
it "returns a list of rpm packages" do | ||
result = described_class.new(fs) | ||
|
||
expect(result.instance_variable_get(:@packages).count).to eq(690) | ||
end | ||
|
||
it "returns relevent information for each package" do | ||
result = described_class.new(fs) | ||
kernel = result.instance_variable_get(:@packages).detect { |p| p.name == 'kernel' } | ||
|
||
expect(kernel.to_h).to include( | ||
"name" => "kernel", | ||
"version" => "2.4.21", | ||
"release" => "50.EL", | ||
"summary" => "The Linux kernel (the core of the Linux operating system)", | ||
"vendor" => "Red Hat, Inc.", | ||
"category" => "System Environment/Kernel", | ||
"arch" => "i686", | ||
"depends" => "rpmlib(VersionedDependencies)\nfileutils\nmodutils\ninitscripts\nmkinitrd\n/bin/sh\nrpmlib(PayloadFilesHavePrefix)\nrpmlib(CompressedFileNames)", | ||
"installed" => true | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package: linux-image-6.11.4-amd64 | ||
Status: install ok installed | ||
Priority: optional | ||
Section: kernel | ||
Installed-Size: 104414 | ||
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org> | ||
Architecture: amd64 | ||
Source: linux-signed-amd64 (6.11.4+1) | ||
Version: 6.11.4-1 | ||
Replaces: linux-image-6.11.4-amd64-unsigned | ||
Depends: kmod, linux-base (>= 4.3~), initramfs-tools (>= 0.120+deb8u2) | linux-initramfs-tool | ||
Recommends: apparmor | ||
Suggests: firmware-linux-free, linux-doc-6.11, debian-kernel-handbook, grub-pc | grub-efi-amd64 | extlinux | ||
Breaks: fwupdate (<< 12-7), initramfs-tools (<< 0.120+deb8u2), wireless-regdb (<< 2019.06.03-1~) | ||
Conflicts: linux-image-6.11.4-amd64-unsigned | ||
Description: Linux 6.11 for 64-bit PCs (signed) | ||
The Linux kernel 6.11 and modules for use on PCs with AMD64, Intel 64 or | ||
VIA Nano processors. | ||
. | ||
The kernel image is signed for use with Secure Boot. | ||
Built-Using: linux (= 6.11.4-1) | ||
Homepage: https://www.kernel.org/ |