diff options
author | Jose Asuncion <jose.asuncion@gmail.com> | 2017-08-21 17:41:32 -0700 |
---|---|---|
committer | Jose Asuncion <jose.asuncion@gmail.com> | 2017-08-21 17:43:08 -0700 |
commit | 1bbc6997308dfabe9d83ed4b89dde91b12979fbc (patch) | |
tree | 08a08be3bacf68f97b71ecb2d4d899d936e2428b /spec | |
parent | 74ae9b00ba4698a4097759506b3f844ee7f94e2d (diff) | |
download | ohai-1bbc6997308dfabe9d83ed4b89dde91b12979fbc.tar.gz |
add error handling
Signed-off-by: Jose Asuncion <jeunito@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/plugins/linux/filesystem_spec.rb | 12 |
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..72aa8f02 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 event" do + allow(plugin).to receive(:which).with(command).and_return(nil) + expect(Ohai::Log).to receive(:warn).with("#{command} is not available") + plugin.run + end + end + end end |