Skip to content

Commit

Permalink
Add spec tests covering existing berkeley db version
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Oct 31, 2024
1 parent f8ee827 commit c5441ac
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions spec/metadata/linux/LinuxPackages_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 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

0 comments on commit c5441ac

Please sign in to comment.