-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pluggable Server Roles #22918
Pluggable Server Roles #22918
Conversation
@@ -55,7 +55,7 @@ | |||
web_services,Web Services,0,false,region | |||
CSV | |||
|
|||
allow(File).to receive(:open).and_return(StringIO.new(@csv)) | |||
allow(File).to receive(:open).with(ServerRole.fixture_path, "r", any_args).and_return(StringIO.new(@csv)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't actually necessary, I just don't think mocking File.open
without any args is error prone
794120d
to
04ee52f
Compare
spec/models/server_role_spec.rb
Outdated
@@ -55,7 +55,11 @@ | |||
web_services,Web Services,0,false,region | |||
CSV | |||
|
|||
allow(File).to receive(:open).and_return(StringIO.new(@csv)) | |||
allow(File).to receive(:exist?).and_call_original | |||
allow(File).to receive(:exist?).with(a_string_matching(/content\/server_roles.csv/)).and_return(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to switch to using File.exist?(file.to_s)
to make it simpler to stub there here, open to other suggestions on mocking Pathname#exist?
though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to find it, but I've done similar tests for other plugins methods where I want to ensure it will pick up all the files from plugins. See vmdb/plugins_spec.rb. Then, I know I've created seed methods that show handling plugin based content, but I gotta find it.
21ea5ce
to
e8605bb
Compare
lib/vmdb/plugins.rb
Outdated
@server_role_paths ||= filter_map do |engine| | ||
file = engine.root.join("content/server_roles.csv") | ||
file if File.exist?(file.to_s) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a compact
?
I see the if
and that says to me that a nil
could be returned.
So I'm guessing a nil
could come out of filter_map
result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filter_map drops the nil
s for you, this was a rubocop recommendation (replacing .map {}.compact with .filter_map {})
I suggest making this |
e8605bb
to
67c3971
Compare
Changed to use |
Checked commits agrare/manageiq@fdc4907~...67c3971 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
Allow plugins to bring their own server_roles by adding a
content/server_roles.csv
file, for example if we extracted Embedded Ansible into a plugin we could move the embedded_ansible role tomanageiq-providers-embedded_ansible/content/server_roles.csv
:#19440