summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-09-06 07:16:54 -0700
committerGitHub <noreply@github.com>2017-09-06 07:16:54 -0700
commit819a7e39019126474761698c1d3e2a40f114b7fc (patch)
treeb98c50b3a6d5b580f34053bdfaeef0734e8a5a92 /spec
parented190dcb201e4c154177e8bb5fb5e6a5c70bf88e (diff)
parent094ccf036ec26d16219ab65386f4368c8773ef71 (diff)
downloadohai-819a7e39019126474761698c1d3e2a40f114b7fc.tar.gz
Merge pull request #1047 from jeunito/bug/1011
Add error handling in Linux filesystem plugin
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/plugins/linux/filesystem_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb
index 96382b1e..65265cd4 100644
--- a/spec/unit/plugins/linux/filesystem_spec.rb
+++ b/spec/unit/plugins/linux/filesystem_spec.rb
@@ -27,6 +27,8 @@ describe Ohai::System, "Linux filesystem plugin" do
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
allow(plugin).to receive(:which).with("lsblk").and_return(nil)
+ allow(plugin).to receive(:which).with("df").and_return("/bin/df")
+ allow(plugin).to receive(:which).with("mount").and_return("/bin/mount")
allow(plugin).to receive(:which).with("blkid").and_return("/sbin/blkid")
allow(plugin).to receive(:shell_out).with("/sbin/blkid", timeout: 60).and_return(mock_shell_out(0, "", ""))
@@ -529,4 +531,14 @@ BLKID_TYPE
expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
end
end
+
+ %w{df mount}.each do |command|
+ describe "when #{command} does not exist" do
+ it "logs warning about #{command} missing" do
+ allow(plugin).to receive(:shell_out).with(/#{command}/).and_raise(Ohai::Exceptions::Exec)
+ expect(Ohai::Log).to receive(:warn).with("#{command} is not available")
+ plugin.run
+ end
+ end
+ end
end