Sha256: a25968772d185b59a699f602b81fc67ee3070693070f5b7a3fda833c4449e927

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

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

require 'facter'
require 'facter/util/virtual'

describe "Virtual fact" do

    after do
        Facter.clear
    end

  it "should be zone on Solaris when a zone" do
      Facter.fact(:kernel).stubs(:value).returns("SunOS")
      Facter::Util::Virtual.stubs(:zone?).returns(true)
      Facter::Util::Virtual.stubs(:vserver?).returns(false)
      Facter::Util::Virtual.stubs(:xen?).returns(false)
      Facter.fact(:virtual).value.should == "zone"
  end

end

describe "is_virtual fact" do

    after do
        Facter.clear
    end

    it "should be virtual when running on xen" do
       Facter.fact(:kernel).stubs(:value).returns("Linux")
       Facter.fact(:virtual).stubs(:value).returns("xenu")
       Facter.fact(:is_virtual).value.should == true
    end

    it "should be false when running on xen0" do
       Facter.fact(:kernel).stubs(:value).returns("Linux")
       Facter.fact(:virtual).stubs(:value).returns("xen0")
       Facter.fact(:is_virtual).value.should == false
    end

    it "should be true when running on vmware" do
        Facter.fact(:kernel).stubs(:value).returns("Linux")
        Facter.fact(:virtual).stubs(:value).returns("vmware")
        Facter.fact(:is_virtual).value.should == true
    end

    it "should be true when running on openvz" do
        Facter.fact(:kernel).stubs(:value).returns("Linux")
        Facter.fact(:virtual).stubs(:value).returns("openvzve")
        Facter.fact(:is_virtual).value.should == true
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facter-1.5.7 spec/unit/virtual.rb