-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36691 - use 'connectefi scsi' by default
Co-Authored-by: Shimon Shtein <sshtein@redhat.com> Co-Authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
- Loading branch information
1 parent
ca34010
commit 7a77b3c
Showing
5 changed files
with
103 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
test/unit/foreman/templates/snippets/pxegrub2_chainload_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'test_helper' | ||
|
||
class PxeGrub2ChainloadTest < ActiveSupport::TestCase | ||
def renderer | ||
@renderer ||= Foreman::Renderer::SafeModeRenderer | ||
end | ||
|
||
def render_template(host) | ||
@snippet ||= File.read(Rails.root.join('app', 'views', 'unattended', 'provisioning_templates', 'snippet', 'pxegrub2_chainload.erb')) | ||
|
||
source = OpenStruct.new( | ||
name: 'Test', | ||
content: @snippet | ||
) | ||
|
||
scope = Class.new(Foreman::Renderer::Scope::Provisioning).send( | ||
:new, | ||
host: host, | ||
source: source, | ||
variables: { | ||
host: host, | ||
}) | ||
|
||
renderer.render(source, scope) | ||
end | ||
|
||
setup do | ||
@host = FactoryBot.create(:host, :managed, :build => true) | ||
end | ||
|
||
test 'should render connectefi scsi option by default' do | ||
actual = render_template(@host) | ||
|
||
assert_match(/^ *connectefi scsi/, actual) | ||
end | ||
|
||
test 'should not render connectefi option if parameter false' do | ||
FactoryBot.create(:host_parameter, host: @host, name: 'grub2-connectefi', value: 'false') | ||
|
||
actual = render_template(@host) | ||
|
||
assert_no_match(/^ *connectefi/, actual) | ||
end | ||
|
||
test 'should render connectefi option if parameter present' do | ||
FactoryBot.create(:host_parameter, host: @host, name: 'grub2-connectefi', value: 'TESTOPT') | ||
|
||
actual = render_template(@host) | ||
|
||
assert_match(/^ *connectefi TESTOPT/, actual) | ||
end | ||
|
||
test 'should render connectefi option for default template' do | ||
actual = render_template(nil) | ||
|
||
assert_match(/^ *connectefi scsi/, actual) | ||
end | ||
end |