Sha256: da0ae9e2b29a544beec75293d9657a18067b112f2e0d1926fa9be95f0d0eff16

Contents?: true

Size: 1.51 KB

Versions: 52

Compression:

Stored size: 1.51 KB

Contents

#! /usr/bin/env ruby

require 'spec_helper'

describe "Processor facts" do
  describe "processorX facts" do
    expected_proc_list = ["Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz", "Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz"]

    ["aix", "hp-ux", "sunos", "linux", "gnu/kfreebsd"].each do |kernel|
      it "should use the 'models' key from the 'processors' fact on #{kernel}" do
        Facter.fact(:kernel).stubs(:value).returns("#{kernel}")
        Facter.fact("processors").stubs(:value).returns({"count" => 8, "physicalcount" => 4, "models" => expected_proc_list})
        Facter.collection.internal_loader.load(:processor)
        expected_proc_list.each_with_index do |processor, i|
          Facter.fact("processor#{i}").value.should eq processor
        end
      end
    end
  end

  describe "processorcount" do
    it "should use the 'processorcount' key from the 'processors' fact" do
      Facter.fact(:kernel).stubs(:value).returns("linux")
      Facter.fact("processors").stubs(:value).returns({"count" => 8, "physicalcount" => 4 })
      Facter.collection.internal_loader.load(:processor)
      Facter.fact(:processorcount).value.should eq 8
    end
  end

  describe "processor" do
    it "should print the correct CPU Model on OpenBSD" do
      Facter.collection.internal_loader.load(:processor)
      Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
      Facter::Util::POSIX.stubs(:sysctl).with("hw.model").returns('SomeVendor CPU 4.2GHz')
      Facter.fact(:processor).value.should eq "SomeVendor CPU 4.2GHz"
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
facter-2.5.7 spec/unit/processor_spec.rb
facter-2.5.7-x86-mingw32 spec/unit/processor_spec.rb
facter-2.5.7-x64-mingw32 spec/unit/processor_spec.rb
facter-2.5.7-universal-darwin spec/unit/processor_spec.rb
facter-2.5.6-x86-mingw32 spec/unit/processor_spec.rb
facter-2.5.6-x64-mingw32 spec/unit/processor_spec.rb
facter-2.5.6-universal-darwin spec/unit/processor_spec.rb
facter-2.5.6 spec/unit/processor_spec.rb
facter-2.5.5-x86-mingw32 spec/unit/processor_spec.rb
facter-2.5.5-x64-mingw32 spec/unit/processor_spec.rb
facter-2.5.5-universal-darwin spec/unit/processor_spec.rb
facter-2.5.5 spec/unit/processor_spec.rb
facter-2.5.4-x86-mingw32 spec/unit/processor_spec.rb
facter-2.5.4-x64-mingw32 spec/unit/processor_spec.rb
facter-2.5.4-universal-darwin spec/unit/processor_spec.rb
facter-2.5.4 spec/unit/processor_spec.rb
facter-2.5.1 spec/unit/processor_spec.rb
facter-2.5.1-x86-mingw32 spec/unit/processor_spec.rb
facter-2.5.1-x64-mingw32 spec/unit/processor_spec.rb
facter-2.5.1-universal-darwin spec/unit/processor_spec.rb