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

(FACT-2533) Fix for tests/facts/partitions.rb #507

Merged
merged 1 commit into from
May 12, 2020
Merged

Conversation

oanatmaria
Copy link
Contributor

Description of the problem: when retrieving partuuid fact for partitions there is an extra space in it's value
Description of the fix: remove extra space from partuuid value

@oanatmaria oanatmaria added the bugfix Something isn't working label May 12, 2020
@oanatmaria oanatmaria requested review from a team May 12, 2020 13:17
@@ -96,6 +96,7 @@ 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 { |_key, value| value['PARTUUID'] = value['PARTUUID'].gsub(/\s/, '') if value['PARTUUID'] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using https://ruby-doc.org/core-2.7.1/String.html#method-i-rstrip might solve the issue in a single iteration since the problem seems to be caused by the way we are splitting the value and also taking the last extra whitespace

output_hash.each do |key, value|
  output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..-1]]
end
``

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@BogdanIrimie BogdanIrimie merged commit 2a03fee into master May 12, 2020
@BogdanIrimie BogdanIrimie deleted the FACT-2533 branch May 12, 2020 14:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants