File: uniquefile_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (29 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'spec_helper'

describe Puppet::FileSystem::Uniquefile do

  describe "#open_tmp on Windows", :if => Puppet.features.microsoft_windows? do

    describe "with UTF8 characters" do
      include PuppetSpec::Files

      let(:rune_utf8) { "\u16A0\u16C7\u16BB\u16EB\u16D2\u16E6\u16A6\u16EB\u16A0\u16B1\u16A9\u16A0\u16A2\u16B1\u16EB\u16A0\u16C1\u16B1\u16AA\u16EB\u16B7\u16D6\u16BB\u16B9\u16E6\u16DA\u16B3\u16A2\u16D7" }
      let(:temp_rune_utf8) { tmpdir(rune_utf8) }

      it "should use UTF8 characters in TMP,TEMP,TMPDIR environment variable" do
        # Set the temporary environment variables to the UTF8 temp path
        Puppet::Util::Windows::Process.set_environment_variable('TMPDIR', temp_rune_utf8)
        Puppet::Util::Windows::Process.set_environment_variable('TMP', temp_rune_utf8)
        Puppet::Util::Windows::Process.set_environment_variable('TEMP', temp_rune_utf8)

        # Create a unique file
        filename = Puppet::FileSystem::Uniquefile.open_tmp('foo') do |file|
          File.dirname(file.path)
        end

        expect(filename).to eq(temp_rune_utf8)
      end
    end
  end

end