summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/xendomains.rb
blob: dc7e17852f543b3bee51ce6e67bffc0ea374b026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby

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

require 'facter/util/xendomains'

describe Facter::Util::Xendomains do
  describe ".get_domains" do
    it "should return a list of running Xen Domains on Xen0" do
      sample_output_file = File.dirname(__FILE__) + '/../data/xendomains'
      xen0_domains = File.read(sample_output_file)
      Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(xen0_domains)
      Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
    end

    describe "when xm list isn't executable" do
      it "should be nil" do
        Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list').returns(nil)
        Facter::Util::Xendomains.get_domains.should == nil
      end
    end
  end
end