Skip to content

Commit

Permalink
fix(test): fix software related tests (#1355)
Browse files Browse the repository at this point in the history
Tests write to `/run/agama`, which is wrong and will not work unless you
have write permissions.
  • Loading branch information
imobachgs authored Jun 19, 2024
2 parents a5caf80 + dcfbe21 commit 043f87d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions service/test/agama/dbus/software/product_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@

let(:config) { Agama::Config.new }

let(:target_dir) { Dir.mktmpdir }

before do
stub_const("Agama::Software::Manager::TARGET_DIR", target_dir)
allow(config).to receive(:products).and_return(products)
allow(subject).to receive(:dbus_properties_changed)
allow(Agama::ProductReader).to receive(:new).and_call_original
end

after do
FileUtils.rm_r(target_dir)
end

let(:products) do
Expand Down
7 changes: 7 additions & 0 deletions service/test/agama/software/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@
instance_double(Agama::DBus::Clients::Questions)
end

let(:target_dir) { Dir.mktmpdir }

before do
stub_const("Agama::Software::Manager::TARGET_DIR", target_dir)
allow(Yast::Pkg).to receive(:TargetInitialize)
allow(Yast::Pkg).to receive(:TargetFinish)
allow(Yast::Pkg).to receive(:TargetLoad)
Expand All @@ -101,6 +104,10 @@
allow(Agama::ProductReader).to receive(:new).and_call_original
end

after do
FileUtils.rm_r(target_dir)
end

describe "#new" do
before do
allow_any_instance_of(Agama::Software::ProductBuilder)
Expand Down

0 comments on commit 043f87d

Please sign in to comment.