Sha256: 63a7ef861cb8844b3182e1e5c2b0691924fb58ba7fa65e683abe46b486191143

Contents?: true

Size: 1.56 KB

Versions: 44

Compression:

Stored size: 1.56 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

describe "Windows UTF8 environment variables", :if => Puppet::Util::Platform.windows? do
  # The Puppet::Util::Windows::Process class is used to manipulate environment variables as it is known to handle UTF8 characters. Where as the implementation of ENV in ruby does not.
  # before and end all are used to inject environment variables before the test helper 'before_each_test' function is called
  # Do not use before and after hooks in these tests as it may have unintended consequences

  before(:all) {
    @varname = 'test_helper_spec-test_variable'
    @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"

    Puppet::Util::Windows::Process.set_environment_variable(@varname, @rune_utf8)
  }
  after(:all) {
    # Need to cleanup this environment variable otherwise it contaminates any subsequent tests
    Puppet::Util::Windows::Process.set_environment_variable(@varname, nil)
  }

  it "#after_each_test should preserve UTF8 environment variables" do
    envhash = Puppet::Util::Windows::Process.get_environment_strings
    expect(envhash[@varname]).to eq(@rune_utf8)
    # Change the value in the test to force test_helper to restore the environment
    ENV[@varname] = 'bad foo'

    # Prematurely trigger the after_each_test method
    Puppet::Test::TestHelper.after_each_test

    envhash = Puppet::Util::Windows::Process.get_environment_strings
    expect(envhash[@varname]).to eq(@rune_utf8)
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
puppet-6.4.0 spec/integration/test/test_helper_spec.rb
puppet-6.4.0-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.4.0-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.4.0-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-6.0.7 spec/integration/test/test_helper_spec.rb
puppet-6.0.7-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.0.7-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.0.7-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-6.3.0 spec/integration/test/test_helper_spec.rb
puppet-6.3.0-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.3.0-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.3.0-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-6.2.0 spec/integration/test/test_helper_spec.rb
puppet-6.2.0-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.2.0-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.2.0-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-6.0.5 spec/integration/test/test_helper_spec.rb
puppet-6.0.5-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.0.5-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-6.0.5-universal-darwin spec/integration/test/test_helper_spec.rb