Skip to content

Commit

Permalink
Add specs for conarydb packages
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Oct 31, 2024
1 parent 3744a62 commit 34bd6f9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/metadata/linux/LinuxPackages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

before do
allow(fs).to receive(:fileExists?).and_return(false)
allow(fs).to receive(:fileDirectory?).and_return(false)
end

context "with a dpkg status file" do
Expand Down Expand Up @@ -75,4 +76,32 @@
end
end
end

context "with a conarydb file" do
before do
expect(fs).to receive(:fileExists?).with(MiqLinux::Packages::CONARY_FILE).and_return(true)
expect(fs)
.to receive(:fileOpen)
.with(MiqLinux::Packages::CONARY_FILE, "r")
.and_return(File.open(File.expand_path('../../db/MiqSqlite/conary.db', __dir__), "r"))
expect(fs).to receive(:fileSize).twice.with(MiqLinux::Packages::CONARY_FILE).and_return(File.size(File.expand_path('../../db/MiqSqlite/conary.db', __dir__)))
end

it "returns a list of packages" do
result = described_class.new(fs)

expect(result.instance_variable_get(:@packages).count).to eq(212)
end

it "returns relevant information for each package" do
result = described_class.new(fs)
kernel = result.instance_variable_get(:@packages).detect { |p| p.name == 'kernel' }

expect(kernel.to_hash).to include(
:name => "kernel",
:version => "/conary.rpath.com@rpl:devel//1/2.6.19.7-0.3-1",
:installed => true
)
end
end
end

0 comments on commit 34bd6f9

Please sign in to comment.