Skip to content
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

Add fact to store information about the BMC #48

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

jcpunk
Copy link
Contributor

@jcpunk jcpunk commented Apr 11, 2022

In order to ensure I'm not running the wrong raw commands on a BMC, I'll need to fetch what BMC you've got.

@jhoblitt
Copy link
Owner

This looks reasonable. Try bundle exec rake rubocop:auto_correct for the rubo errors.

@jcpunk
Copy link
Contributor Author

jcpunk commented Apr 11, 2022

I think I got it sorted....

@jcpunk
Copy link
Contributor Author

jcpunk commented Apr 11, 2022

hmmm... I'm pretty far out of my depth testing wise here. rubocop doesn't like the expect lines in begin, but when I change them to allow they fail, and when I move them out of begin my tests fail (I've got a local pdk instance I'm using to test)

@jhoblitt
Copy link
Owner

spec_helper.rb is setting the mocking framework to mocha, as that was the de facto standard for puppet mods when this code was originally written. You probably want something like:

diff --git a/spec/unit/facter/ipmitool_mc_info_spec.rb b/spec/unit/facter/ipmitool_mc_info_spec.rb
index 7c609b6..dcaa9e9 100644
--- a/spec/unit/facter/ipmitool_mc_info_spec.rb
+++ b/spec/unit/facter/ipmitool_mc_info_spec.rb
@@ -42,8 +42,8 @@ Aux Firmware Rev Info     :
 
   context 'with no ipmitool' do
     before :each do
-      allow(Facter::Util::Resolution).to receive(:which).with('ipmitool').and_return(nil)
-      allow(Facter::Util::Resolution).not_to receive(:exec).with('ipmitool mc info 2>/dev/null')
+      Facter::Util::Resolution.expects(:which).at_least(1).with('ipmitool').returns(nil)
+      Facter::Util::Resolution.expects(:exec).with('ipmitool mc info 2>/dev/null').never
     end
 
     it do
@@ -53,8 +53,8 @@ Aux Firmware Rev Info     :
 
   context 'with detailed output' do
     before :each do
-      allow(Facter::Util::Resolution).to receive(:which).with('ipmitool').and_return('ipmitool')
-      allow(Facter::Util::Resolution).to receive(:exec).with('ipmitool mc info 2>/dev/null').and_return(detailed_output)
+      Facter::Util::Resolution.expects(:which).with('ipmitool').returns('ipmitool')
+      Facter::Util::Resolution.expects(:exec).with('ipmitool mc info 2>/dev/null').returns(detailed_output)
     end
 
     it do

@jcpunk
Copy link
Contributor Author

jcpunk commented Apr 11, 2022

My pdk tests don't like these changes, but I've put them in here hopefully they behave...

@jhoblitt
Copy link
Owner

I'm not sure what you mean by "pdk tests"? pdk test unit shouldn't work at all in this module. build exec rake will run rspec tests.

@jhoblitt jhoblitt merged commit 5634cf9 into jhoblitt:master Apr 11, 2022
@jhoblitt
Copy link
Owner

Released as 3.1.0.

@jcpunk jcpunk deleted the ipmitool_mc_info branch April 12, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants