Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jun 30, 2020
1 parent 9366ad0 commit e69f9a9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/clients/inst_autosetup.rb
Expand Up @@ -457,7 +457,7 @@ def add_yast2_dependencies
end

def importer
Y2Autoinstallation::Entries::Importer.new(Profile.current)
@importer ||= Y2Autoinstallation::Entries::Importer.new(Profile.current)
end
end
end
Expand Down
1 change: 0 additions & 1 deletion src/include/autoinstall/conftree.rb
Expand Up @@ -536,7 +536,6 @@ def MainDialog
modulename = getModule
if modulename != ""
d = Ops.get(Y2ModuleConfig.ModuleMap, modulename, {})
module_auto = ""
module_auto = if Builtins.haskey(d, "X-SuSE-YaST-AutoInstClient")
Ops.get_string(
d,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/autoinstall/clients/inst_autoinit.rb
Expand Up @@ -136,7 +136,8 @@ def run

# Checking profile for unsupported sections.
def check_unsupported_profile_sections
unsupported_sections = Y2Autoinstallation::Entries::Importer.new(Profile.current).obsolete_sections
unsupported_sections = Y2Autoinstallation::Entries::Importer.new(Yast::Profile.current)
.obsolete_sections
if unsupported_sections.any?
log.error "Could not process these unsupported profile " \
"sections: #{unsupported_sections}"
Expand Down
7 changes: 4 additions & 3 deletions src/lib/autoinstall/entries/importer.rb
Expand Up @@ -17,7 +17,7 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "autoinstallation/entries/registry"
require "autoinstall/entries/registry"

module Y2Autoinstallation
module Entries
Expand Down Expand Up @@ -103,7 +103,7 @@ def import_entry(entry)
profile[description.managed_keys.first]
else
key = description.aliases.find { |a| profile.key?(a) }
next unless key
return res unless key

res << key
profile[key]
Expand All @@ -117,9 +117,10 @@ def import_entry(entry)
Yast::WFM.CallFunction(description.client_name, ["Import", data]) if data
else
raise "Unknown entry #{entry}" unless WFM.ClientExists("#{entry}_auto")

data = profile[entry]
if data
Yast::WFM.CallFunction("#{entry}_auto", ["Import", data])
Yast::WFM.CallFunction("#{entry}_auto", ["Import", data])
res << entry
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/lib/autoinstall/entries/registry.rb
Expand Up @@ -18,7 +18,7 @@
# find current contact information at www.suse.com.

require "singleton"
require "autoinstallation/entries/description"
require "autoinstall/entries/description"

Yast.import "Desktop"

Expand All @@ -29,7 +29,7 @@ class Registry
include Singleton

def read
Yast::Desktop.AgentPath = path(".autoyast2.desktop")
Yast::Desktop.AgentPath = Yast::Path.new(".autoyast2.desktop")
Yast::Desktop.Read(Description::USED_VALUES)
@descriptions = Yast::Desktop.Modules.map { |_, v| Description.new(v) }
@groups = Yast::Desktop.Groups
Expand Down
30 changes: 2 additions & 28 deletions test/Y2ModuleConfig_test.rb
Expand Up @@ -21,35 +21,9 @@
subject.main
end

describe "#unhandled_profile_sections" do
let(:profile_unhandled) { File.join(FIXTURES_PATH, "profiles", "unhandled_and_obsolete.xml") }

it "returns all unsupported and unknown profile sections" do
Yast::Profile.ReadXML(profile_unhandled)

expect(Yast::Y2ModuleConfig.unhandled_profile_sections).to contain_exactly(
"audit-laf", "autofs", "ca_mgm", "cobbler", "firstboot", "inetd", "language",
"restore", "security", "sshd", "sysconfig", "unknown_profile_item_1",
"unknown_profile_item_2"
)
end
end

describe "#unsupported_profile_sections" do
let(:profile_unsupported) { File.join(FIXTURES_PATH, "profiles", "unhandled_and_obsolete.xml") }

it "returns all unsupported profile sections" do
Yast::Profile.ReadXML(profile_unsupported)

expect(Yast::Y2ModuleConfig.unsupported_profile_sections).to contain_exactly(
"autofs", "ca_mgm", "cobbler", "inetd", "restore", "sshd"
)
end
end

describe "#ReadMenuEntries" do
it "returns the modules and groups for the given modes" do
modules, groups = subject.ReadMenuEntries(["configure"])
modules, groups = subject.send(:ReadMenuEntries, ["configure"])
expect(modules.keys).to eq(
["add-on", "bootloader", "general", "partitioning", "report", "software"]
)
Expand All @@ -59,7 +33,7 @@
end

it "sets the client if missing" do
modules, _groups = subject.ReadMenuEntries(["configure"])
modules, _groups = subject.send(:ReadMenuEntries, ["configure"])
add_on = modules["add-on"]
expect(add_on["X-SuSE-YaST-AutoInstClient"]).to eq("add-on_auto")
end
Expand Down
62 changes: 0 additions & 62 deletions test/lib/module_config_builder_test.rb

This file was deleted.

0 comments on commit e69f9a9

Please sign in to comment.