Skip to content

Commit 36251a4

Browse files
committed
(PUP-10640) make tests more reliable
the following tests have been updated - spec/integration/util/windows/adsi_spec.rb:34 Was making the assumption that `Administrator` user is present. Changed to `Guest` since `Administrator` is not available in all setups. - spec/unit/file_system_spec.rb:870 `Puppet::FileSystem.expand_path` expands relative to the drive that Puppet is executed from. The expect here was making the assumption that Puppet tests are run form `SystemDrive` which is not always the case. Updated the test to match that the expanded path starts with a drive letter. - spec/unit/provider/exec_spec.rb ENV['PATH'] is not correctly handled by Ruby. Use Pathname.cleanpath no normalize the path that is used in the `exec` resource
1 parent dd06db6 commit 36251a4

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

spec/integration/util/windows/adsi_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
describe '.[]' do
3535
it 'should return string attributes as UTF-8' do
36-
administrator = Puppet::Util::Windows::ADSI::User.new('Administrator')
36+
administrator = Puppet::Util::Windows::ADSI::User.new('Guest')
3737
expect(administrator['Description'].encoding).to eq(Encoding::UTF_8)
3838
end
3939
end

spec/unit/file_system_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,7 @@ def increment_counter_in_multiple_processes(file, num_procs, options)
871871
it "should return the absolute path including system drive letter when given #{slash}, like Ruby File.expand_path" do
872872

873873
# regardless of slash direction, return value is drive letter
874-
expanded = Puppet::FileSystem.expand_path(slash)
875-
expect(expanded).to eq(ENV['SystemDrive'] + File::SEPARATOR)
876-
expect(expanded).to eq(File.expand_path(slash))
874+
expect(expanded).to match(/^[a-z]:/i)
877875
end
878876
end
879877

spec/unit/provider/exec_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@
4949
# we can't reference that in our manifest. Windows PATHs can contain
5050
# double quotes and trailing backslashes, which confuse HEREDOC
5151
# interpolation below. So sanitize it:
52-
ENV['PATH'].split(File::PATH_SEPARATOR).map do |dir|
53-
dir.gsub(/"/, '\"').gsub(/\\$/, '')
54-
end.join(File::PATH_SEPARATOR)
52+
ENV['PATH'].split(File::PATH_SEPARATOR)
53+
.map { |dir| dir.gsub(/"/, '\"').gsub(/\\$/, '') }
54+
.map { |dir| Pathname.new(dir).cleanpath.to_s }
55+
.join(File::PATH_SEPARATOR)
5556
else
5657
ENV['PATH']
5758
end

0 commit comments

Comments
 (0)