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

Commit

Permalink
(FACT-2533) Fix for tests/facts/partitions.rb (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
oanatmaria authored May 12, 2020
1 parent d609416 commit 2a03fee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/resolvers/partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def blkid_command?
def execute_and_extract_blkid_info
stdout = Facter::Core::Execution.execute('blkid', logger: log)
output_hash = Hash[*stdout.split(/^([^:]+):/)[1..-1]]
output_hash.each { |key, value| output_hash[key] = Hash[*value.delete('"').chomp.split(/ ([^= ]+)=/)[1..-1]] }
output_hash.each do |key, value|
output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..-1]]
end
end

def browse_subdirectories(path)
Expand Down
5 changes: 3 additions & 2 deletions spec/facter/resolvers/partitions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
context 'when device size files are readable' do
let(:partitions) do
{ '/dev/sda1' => { filesystem: 'ext3', label: '/boot', size: '117.00 KiB',
size_bytes: 119_808, uuid: '88077904-4fd4-476f-9af2-0f7a806ca25e' },
size_bytes: 119_808, uuid: '88077904-4fd4-476f-9af2-0f7a806ca25e',
partuuid: '00061fe0-01' },
'/dev/sda2' => { size: '98.25 MiB', size_bytes: 103_021_056 } }
end

Expand All @@ -63,7 +64,7 @@
context 'when device size files are not readable' do
let(:partitions_with_no_sizes) do
{ '/dev/sda1' => { filesystem: 'ext3', label: '/boot', size: '0 bytes',
size_bytes: 0, uuid: '88077904-4fd4-476f-9af2-0f7a806ca25e' },
size_bytes: 0, uuid: '88077904-4fd4-476f-9af2-0f7a806ca25e', partuuid: '00061fe0-01' },
'/dev/sda2' => { size: '0 bytes', size_bytes: 0 } }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/blkid_output
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/dev/mapper/VolGroup00-LogVol01: TYPE="swap"
/dev/mapper/VolGroup00-LogVol00: UUID="1bd8643b-483a-4fdc-adcd-c586384919a8" TYPE="ext3"
/dev/sda1: LABEL="/boot" UUID="88077904-4fd4-476f-9af2-0f7a806ca25e" TYPE="ext3" SEC_TYPE="ext2"
/dev/sda1: LABEL="/boot" UUID="88077904-4fd4-476f-9af2-0f7a806ca25e" TYPE="ext3" SEC_TYPE="ext2" PARTUUID="00061fe0-01 "
/dev/hdc: LABEL="VMware Tools" TYPE="iso9660"
/dev/VolGroup00/LogVol00: UUID="1bd8643b-483a-4fdc-adcd-c586384919a8" TYPE="ext3"
/dev/VolGroup00/LogVol01: TYPE="swap"
Expand Down

0 comments on commit 2a03fee

Please sign in to comment.