Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Fixes issue with empty fact #74

Merged
merged 1 commit into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/facter/swapfile_sizes_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

end

swapfile_csv = swap_file_array.join(',')
swapfile_csv = swap_file_array.join(',') unless swap_file_array.empty?

Facter.add('swapfile_sizes_csv') do
confine :kernel => 'Linux'
Expand Down
17 changes: 17 additions & 0 deletions spec/unit/facter/swapfiles_fact_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,22 @@
end
end

context 'returns nil when no swapfiles' do
before do
Facter.fact(:kernel).stubs(:value).returns("Linux")
File.stubs(:exists?)
File.expects(:exists?).with('/proc/swaps').returns(true)
Facter::Util::Resolution.stubs(:exec)
end
it do
proc_swap_output = <<-EOS
Filename Type Size Used Priority
/dev/dm-2 partition 16612860 0 -1
EOS
Facter::Util::Resolution.expects(:exec).with('cat /proc/swaps').returns(proc_swap_output)
expect(Facter.value(:swapfile_sizes_csv)).to eq(nil)
end
end

end
end