Sha256: e0bfd8e3c745a449f7eb123d43f248360c0acd07e25a90278fc656494f08b2ba

Contents?: true

Size: 1.72 KB

Versions: 15

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe Hiera::Util do
  describe 'Hiera::Util.posix?' do
    it 'should return true on posix systems' do
      Etc.expects(:getpwuid).with(0).returns(true)
      expect(Hiera::Util.posix?).to be_truthy
    end

    it 'should return false on non posix systems' do
      Etc.expects(:getpwuid).with(0).returns(nil)
      expect(Hiera::Util.posix?).to be_falsey
    end
  end

  describe 'Hiera::Util.microsoft_windows?' do
    it 'should return false on posix systems' do
      Hiera::Util.expects(:file_alt_separator).returns(nil)
      expect(Hiera::Util.microsoft_windows?).to be_falsey
    end
  end

  describe 'Hiera::Util.config_dir' do
    it 'should return the correct path for posix systems' do
      Hiera::Util.expects(:file_alt_separator).returns(nil)
      expect(Hiera::Util.config_dir).to eq('/etc/puppetlabs/code')
    end

    it 'should return the correct path for microsoft windows systems' do
      Hiera::Util.expects(:microsoft_windows?).returns(true)
      Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
      expect(Hiera::Util.config_dir).to eq('C:\\ProgramData/PuppetLabs/code')
    end
  end

  describe 'Hiera::Util.var_dir' do
    it 'should return the correct path for posix systems' do
      Hiera::Util.expects(:file_alt_separator).returns(nil)
      expect(Hiera::Util.var_dir).to eq('/etc/puppetlabs/code/environments/%{environment}/hieradata')
    end

    it 'should return the correct path for microsoft windows systems' do
      Hiera::Util.expects(:microsoft_windows?).returns(true)
      Hiera::Util.expects(:common_appdata).returns('C:\\ProgramData')
      expect(Hiera::Util.var_dir).to eq('C:\\ProgramData/PuppetLabs/code/environments/%{environment}/hieradata')
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hiera-3.1.2 spec/unit/util_spec.rb
hiera-3.1.2-x86-mingw32 spec/unit/util_spec.rb
hiera-3.1.2-x64-mingw32 spec/unit/util_spec.rb
hiera-3.1.1 spec/unit/util_spec.rb
hiera-3.1.1-x86-mingw32 spec/unit/util_spec.rb
hiera-3.1.1-x64-mingw32 spec/unit/util_spec.rb
hiera-3.1.0 spec/unit/util_spec.rb
hiera-3.1.0-x86-mingw32 spec/unit/util_spec.rb
hiera-3.1.0-x64-mingw32 spec/unit/util_spec.rb
hiera-3.0.6 spec/unit/util_spec.rb
hiera-3.0.6-x86-mingw32 spec/unit/util_spec.rb
hiera-3.0.6-x64-mingw32 spec/unit/util_spec.rb
hiera-3.0.5 spec/unit/util_spec.rb
hiera-3.0.5-x86-mingw32 spec/unit/util_spec.rb
hiera-3.0.5-x64-mingw32 spec/unit/util_spec.rb