Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jan 24, 2024
1 parent fa7f458 commit 0a6da37
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions test/cio_ignore_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,28 @@
end

describe "cio_ignore enable/disable" do
it "take AutoYaST cio_ignore setting" do
allow(Yast::Mode).to receive(:autoinst).and_return(true)
allow(Yast::AutoinstConfig).to receive(:cio_ignore).and_return(false)
::Installation::CIOIgnore.instance.reset
expect(::Installation::CIOIgnore.instance.cio_enabled).to eq(false)
let(:auto) { false }

before do
allow(Yast::Mode).to receive(:autoinst).and_return(auto)
end

context "in autoinstallation" do
let(:auto) { true }

it "takes AutoYaST cio_ignore setting" do
allow(Yast::AutoinstConfig).to receive(:cio_ignore).and_return(false)
::Installation::CIOIgnore.instance.reset
expect(::Installation::CIOIgnore.instance.cio_enabled).to eq(false)
end
end

it "take default cio_ignore entry if it is in the normal workflow" do
allow(Yast::Mode).to receive(:autoinst).and_return(false)
expect(Yast::AutoinstConfig).not_to receive(:cio_ignore)
expect(File).to receive(:exist?).with("/proc/sysinfo").exactly(2).times.and_return(false)
::Installation::CIOIgnore.instance.reset
expect(::Installation::CIOIgnore.instance.cio_enabled).to eq(true)
context "in other modes" do
it "takes the default cio_ignore entry" do
expect(yast::autoinstconfig).not_to receive(:cio_ignore)
::Installation::cioignore.instance.reset
expect(::Installation::cioignore.instance.cio_enabled).to eq(true)
end
end
end
end
Expand Down Expand Up @@ -169,7 +178,7 @@
allow(Yast::Bootloader).to receive(:Read) { true }
allow(Yast::Bootloader).to receive(:modify_kernel_params) { true }

allow(Yast::SCR).to receive(:Execute)
allow(Yast::WFM).to receive(:Execute)
.and_return("exit" => 0, "stdout" => "", "stderr" => "")

allow(File).to receive(:write)
Expand All @@ -179,7 +188,7 @@
it "does nothing" do
::Installation::CIOIgnore.instance.cio_enabled = false

expect(Yast::SCR).to_not receive(:Execute)
expect(Yast::WFM).to_not receive(:Execute)
expect(Yast::Bootloader).to_not receive(:Read)

subject.run("Write")
Expand All @@ -190,9 +199,9 @@
it "calls `cio_ignore --unused --purge`" do
::Installation::CIOIgnore.instance.cio_enabled = true

expect(Yast::SCR).to receive(:Execute)
expect(Yast::WFM).to receive(:Execute)
.with(
::Installation::CIOIgnoreFinish::YAST_BASH_PATH,
::Installation::CIOIgnoreFinish::YAST_LOCAL_BASH_PATH,
"/sbin/cio_ignore --unused --purge"
)
.once
Expand All @@ -205,9 +214,9 @@
::Installation::CIOIgnore.instance.cio_enabled = true
stderr = "HORRIBLE ERROR!!!"

expect(Yast::SCR).to receive(:Execute)
expect(Yast::WFM).to receive(:Execute)
.with(
::Installation::CIOIgnoreFinish::YAST_BASH_PATH,
::Installation::CIOIgnoreFinish::YAST_LOCAL_BASH_PATH,
"/sbin/cio_ignore --unused --purge"
)
.once
Expand All @@ -233,9 +242,9 @@
0.0.0700-0.0.0702
0.0.fc00
CIO_IGNORE
expect(Yast::SCR).to receive(:Execute)
expect(Yast::WFM).to receive(:Execute)
.with(
::Installation::CIOIgnoreFinish::YAST_BASH_PATH,
::Installation::CIOIgnoreFinish::YAST_LOCAL_BASH_PATH,
"/sbin/cio_ignore -L"
)
.once
Expand All @@ -251,9 +260,9 @@
end

it "raises an exception if cio_ignore -L failed" do
expect(Yast::SCR).to receive(:Execute)
expect(Yast::WFM).to receive(:Execute)
.with(
::Installation::CIOIgnoreFinish::YAST_BASH_PATH,
::Installation::CIOIgnoreFinish::YAST_LOCAL_BASH_PATH,
"/sbin/cio_ignore -L"
)
.once
Expand Down

0 comments on commit 0a6da37

Please sign in to comment.