From dcfbe211d95c46798e9b7800b4e919672c40b47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Tue, 18 Jun 2024 20:00:20 +0100 Subject: [PATCH] fix(test): fix software related tests * The tests are writing to /run/agama, which is wrong and will not work unless you run them as root. --- service/test/agama/dbus/software/product_test.rb | 8 ++++++++ service/test/agama/software/manager_test.rb | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/service/test/agama/dbus/software/product_test.rb b/service/test/agama/dbus/software/product_test.rb index e25c36e661..72e1ee7438 100644 --- a/service/test/agama/dbus/software/product_test.rb +++ b/service/test/agama/dbus/software/product_test.rb @@ -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 diff --git a/service/test/agama/software/manager_test.rb b/service/test/agama/software/manager_test.rb index e578508766..f5b7470829 100644 --- a/service/test/agama/software/manager_test.rb +++ b/service/test/agama/software/manager_test.rb @@ -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) @@ -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)