From 8e8923994a3a790e488825ccf7a50aff9ab6c50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Thu, 23 May 2024 23:34:12 +0100 Subject: [PATCH] test(service): add an AutoYaST rules test --- service/test/agama/autoyast/converter_test.rb | 24 +++++++++++++++++++ .../fixtures/profiles/profile/rules/rules.xml | 19 +++++++++++++++ .../fixtures/profiles/profile/testing.xml | 14 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 service/test/fixtures/profiles/profile/rules/rules.xml create mode 100644 service/test/fixtures/profiles/profile/testing.xml diff --git a/service/test/agama/autoyast/converter_test.rb b/service/test/agama/autoyast/converter_test.rb index ae39c1a0f4..a61e940678 100644 --- a/service/test/agama/autoyast/converter_test.rb +++ b/service/test/agama/autoyast/converter_test.rb @@ -24,6 +24,7 @@ require "json" require "tmpdir" require "autoinstall/xml_checks" +require "y2storage" describe Agama::AutoYaST::Converter do let(:profile) { File.join(FIXTURES_PATH, "profiles", profile_name) } @@ -43,6 +44,19 @@ content = File.read(File.join(workdir, "autoinst.json")) JSON.parse(content) end + let(:storage_manager) do + instance_double( + Y2Storage::StorageManager, + probed: storage_probed, + probed_disk_analyzer: disk_analyzer + ) + end + let(:storage_probed) do + instance_double(Y2Storage::Devicegraph, disks: []) + end + let(:disk_analyzer) do + instance_double(Y2Storage::DiskAnalyzer, windows_partitions: [], linux_partitions: []) + end before do stub_const("Y2Autoinstallation::XmlChecks::ERRORS_PATH", File.join(tmpdir, "errors")) @@ -55,6 +69,7 @@ allow(Yast::AutoinstConfig).to receive(:modified_profile) .and_return(File.join(tmpdir, "profile", "modified.xml")) allow(Y2Autoinstallation::XmlValidator).to receive(:new).and_return(xml_validator) + allow(Y2Storage::StorageManager).to receive(:instance).and_return(storage_manager) end after do @@ -100,6 +115,15 @@ end end + context "when the profile uses rules" do + let(:profile_name) { "profile/" } + + it "evaluates the rules" do + subject.to_agama(workdir) + expect(result["product"]).to include("id" => "Tumbleweed") + end + end + context "when a product is selected" do it "exports the selected product" do subject.to_agama(workdir) diff --git a/service/test/fixtures/profiles/profile/rules/rules.xml b/service/test/fixtures/profiles/profile/rules/rules.xml new file mode 100644 index 0000000000..36cbe9852c --- /dev/null +++ b/service/test/fixtures/profiles/profile/rules/rules.xml @@ -0,0 +1,19 @@ + + + + + + + + * + exact + + + @custom1@ + false + + + + diff --git a/service/test/fixtures/profiles/profile/testing.xml b/service/test/fixtures/profiles/profile/testing.xml new file mode 100644 index 0000000000..6370b2b082 --- /dev/null +++ b/service/test/fixtures/profiles/profile/testing.xml @@ -0,0 +1,14 @@ + + + + + + Tumbleweed + + + enhanced_base + + + + +