Sha256: b93c1b00996b1039b83b052fb84b81fff6dbefce1c4026323f0fd38b6c72bcc4

Contents?: true

Size: 1.74 KB

Versions: 12

Compression:

Stored size: 1.74 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

require 'facter'

describe "Operating System Release fact" do

  before do
    Facter.clear
  end

  after do
    Facter.clear
  end

  test_cases = {
    "CentOS"    => "/etc/redhat-release",
    "RedHat"    => "/etc/redhat-release",
    "Scientific"  => "/etc/redhat-release",
    "Fedora"    => "/etc/fedora-release",
    "MeeGo"     => "/etc/meego-release",
    "OEL"     => "/etc/enterprise-release",
    "oel"     => "/etc/enterprise-release",
    "OVS"     => "/etc/ovs-release",
    "ovs"     => "/etc/ovs-release",
    "OracleLinux" => "/etc/oracle-release",
    "Ascendos"    => "/etc/redhat-release",
  }

  test_cases.each do |system, file|
    describe "with operatingsystem reported as #{system.inspect}" do
      it "should read the #{file.inspect} file" do
        Facter.fact(:operatingsystem).stubs(:value).returns(system)

        File.expects(:open).with(file, "r").at_least(1)

        Facter.fact(:operatingsystemrelease).value
      end
    end
  end

  it "for VMWareESX it should run the vmware -v command" do
    Facter.fact(:kernel).stubs(:value).returns("VMkernel")
    Facter.fact(:kernelrelease).stubs(:value).returns("4.1.0")
    Facter.fact(:operatingsystem).stubs(:value).returns("VMwareESX")

    Facter::Util::Resolution.stubs(:exec).with('vmware -v').returns('foo')

    Facter.fact(:operatingsystemrelease).value
  end

  it "for Alpine it should use the contents of /etc/alpine-release" do
    Facter.fact(:kernel).stubs(:value).returns("Linux")
    Facter.fact(:operatingsystem).stubs(:value).returns("Alpine")

    File.expects(:read).with("/etc/alpine-release").returns("foo")

    Facter.fact(:operatingsystemrelease).value.should == "foo"
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/facter-1.6.4/spec/unit/operatingsystemrelease_spec.rb
facter-1.6.4 spec/unit/operatingsystemrelease_spec.rb
facter-1.6.3 spec/unit/operatingsystemrelease_spec.rb