Skip to content

Commit

Permalink
Merge pull request #2684 from joshcooper/os_windows
Browse files Browse the repository at this point in the history
Fetch the registry value not the type
  • Loading branch information
mhashizume authored Mar 1, 2024
2 parents 5a7ad83 + 1df07b2 commit 0d2dcdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/facter/resolvers/windows/product_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read_fact_from_registry(fact_name)
end

def build_fact_list(reg)
reg.each do |name, value|
reg.each do |name, _type, value|
case name
when 'EditionID'
@fact_list[:edition_id] = value
Expand Down
14 changes: 8 additions & 6 deletions spec/facter/resolvers/windows/product_release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
let(:prod) { 'Windows Server 2022 Standard' }
let(:release) { '1809' }
let(:display_version) { '21H2' }
# https://github.com/ruby/ruby/blob/6da8f04e01fd85e54a641c6ec4816153b9557095/ext/win32/lib/win32/registry.rb#L114
let(:reg_sz) { 1 }

before do
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion')
.and_return(reg)
allow(reg).to receive(:each)
.and_yield('EditionID', ed)
.and_yield('InstallationType', install)
.and_yield('ProductName', prod)
.and_yield('ReleaseId', release)
.and_yield('DisplayVersion', display_version)
.and_yield('EditionID', reg_sz, ed)
.and_yield('InstallationType', reg_sz, install)
.and_yield('ProductName', reg_sz, prod)
.and_yield('ReleaseId', reg_sz, release)
.and_yield('DisplayVersion', reg_sz, display_version)

allow(reg).to receive(:close)
end
Expand Down Expand Up @@ -79,7 +81,7 @@
.with('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion')
.and_return(reg)
allow(reg).to receive(:each)
.and_yield('ReleaseId', release)
.and_yield('ReleaseId', reg_sz, release)

allow(reg).to receive(:close)
end
Expand Down

0 comments on commit 0d2dcdb

Please sign in to comment.