bugfix: handle empty processes result

This commit is contained in:
Dominik Richter 2015-10-26 16:47:54 +01:00
parent ec6d1e680a
commit 414bf6b1fa
2 changed files with 6 additions and 0 deletions

View file

@ -31,6 +31,7 @@ class Processes < Inspec.resource(1)
# get all running processes
cmd = inspec.command('ps aux')
all = cmd.stdout.split("\n")[1..-1]
return [] if all.nil?
lines = all.map do |line|
# user 32296 0.0 0.0 42592 7972 pts/15 Ss+ Apr06 0:00 zsh

View file

@ -6,6 +6,11 @@ require 'helper'
require 'inspec/resource'
describe 'Inspec::Resources::Processes' do
it 'handles empty process results' do
resource = load_resource('processes', 'nothing')
_(resource.list).must_equal []
end
it 'verify processes resource' do
resource = load_resource('processes', '/bin/bash')
_(resource.list).must_equal [{