Skip to content

Commit

Permalink
fix(test): fix software related tests
Browse files Browse the repository at this point in the history
* The tests are writing to /run/agama, which is
  wrong and will not work unless you run them as
  root.
  • Loading branch information
imobachgs committed Jun 18, 2024
1 parent a5caf80 commit dcfbe21
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 dcfbe21

Please sign in to comment.